<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span class="hs-cpp">

#if !MIN_VERSION_base(4, 8, 0)
</span><span class="hs-comment">-- In base-4.8.0 the Foreign module became Safe</span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-8"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Module      :  System.Directory</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2001</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Stability   :  stable</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- System-independent interface to directory manipulation.</span><span>
</span><span id="line-19"></span><span class="hs-comment">--</span><span>
</span><span id="line-20"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Directory</span><span>
</span><span id="line-23"></span><span>   </span><span class="hs-special">(</span><span>
</span><span id="line-24"></span><span>    </span><span class="annot"><span class="hs-comment">-- $intro</span></span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Actions on directories</span></span><span>
</span><span id="line-27"></span><span>      </span><span class="annot"><a href="System.Directory.html#createDirectory"><span class="hs-identifier">createDirectory</span></a></span><span>
</span><span id="line-28"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#createDirectoryIfMissing"><span class="hs-identifier">createDirectoryIfMissing</span></a></span><span>
</span><span id="line-29"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#removeDirectory"><span class="hs-identifier">removeDirectory</span></a></span><span>
</span><span id="line-30"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#removeDirectoryRecursive"><span class="hs-identifier">removeDirectoryRecursive</span></a></span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#removePathForcibly"><span class="hs-identifier">removePathForcibly</span></a></span><span>
</span><span id="line-32"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#renameDirectory"><span class="hs-identifier">renameDirectory</span></a></span><span>
</span><span id="line-33"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#listDirectory"><span class="hs-identifier">listDirectory</span></a></span><span>
</span><span id="line-34"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getDirectoryContents"><span class="hs-identifier">getDirectoryContents</span></a></span><span>
</span><span id="line-35"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Current working directory</span></span><span>
</span><span id="line-36"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getCurrentDirectory"><span class="hs-identifier">getCurrentDirectory</span></a></span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#setCurrentDirectory"><span class="hs-identifier">setCurrentDirectory</span></a></span><span>
</span><span id="line-38"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#withCurrentDirectory"><span class="hs-identifier">withCurrentDirectory</span></a></span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Pre-defined directories</span></span><span>
</span><span id="line-41"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getHomeDirectory"><span class="hs-identifier">getHomeDirectory</span></a></span><span>
</span><span id="line-42"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#XdgDirectory"><span class="hs-identifier">XdgDirectory</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getXdgDirectory"><span class="hs-identifier">getXdgDirectory</span></a></span><span>
</span><span id="line-44"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#XdgDirectoryList"><span class="hs-identifier">XdgDirectoryList</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-45"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getXdgDirectoryList"><span class="hs-identifier">getXdgDirectoryList</span></a></span><span>
</span><span id="line-46"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getAppUserDataDirectory"><span class="hs-identifier">getAppUserDataDirectory</span></a></span><span>
</span><span id="line-47"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getUserDocumentsDirectory"><span class="hs-identifier">getUserDocumentsDirectory</span></a></span><span>
</span><span id="line-48"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getTemporaryDirectory"><span class="hs-identifier">getTemporaryDirectory</span></a></span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Actions on files</span></span><span>
</span><span id="line-51"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#removeFile"><span class="hs-identifier">removeFile</span></a></span><span>
</span><span id="line-52"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#renameFile"><span class="hs-identifier">renameFile</span></a></span><span>
</span><span id="line-53"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#renamePath"><span class="hs-identifier">renamePath</span></a></span><span>
</span><span id="line-54"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#copyFile"><span class="hs-identifier">copyFile</span></a></span><span>
</span><span id="line-55"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#copyFileWithMetadata"><span class="hs-identifier">copyFileWithMetadata</span></a></span><span>
</span><span id="line-56"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getFileSize"><span class="hs-identifier">getFileSize</span></a></span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#canonicalizePath"><span class="hs-identifier">canonicalizePath</span></a></span><span>
</span><span id="line-59"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#makeAbsolute"><span class="hs-identifier">makeAbsolute</span></a></span><span>
</span><span id="line-60"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#makeRelativeToCurrentDirectory"><span class="hs-identifier">makeRelativeToCurrentDirectory</span></a></span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Existence tests</span></span><span>
</span><span id="line-63"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#doesPathExist"><span class="hs-identifier">doesPathExist</span></a></span><span>
</span><span id="line-64"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#doesFileExist"><span class="hs-identifier">doesFileExist</span></a></span><span>
</span><span id="line-65"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#doesDirectoryExist"><span class="hs-identifier">doesDirectoryExist</span></a></span><span>
</span><span id="line-66"></span><span>
</span><span id="line-67"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#findExecutable"><span class="hs-identifier">findExecutable</span></a></span><span>
</span><span id="line-68"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#findExecutables"><span class="hs-identifier">findExecutables</span></a></span><span>
</span><span id="line-69"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#findExecutablesInDirectories"><span class="hs-identifier">findExecutablesInDirectories</span></a></span><span>
</span><span id="line-70"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#findFile"><span class="hs-identifier">findFile</span></a></span><span>
</span><span id="line-71"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#findFiles"><span class="hs-identifier">findFiles</span></a></span><span>
</span><span id="line-72"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#findFileWith"><span class="hs-identifier">findFileWith</span></a></span><span>
</span><span id="line-73"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#findFilesWith"><span class="hs-identifier">findFilesWith</span></a></span><span>
</span><span id="line-74"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#exeExtension"><span class="hs-identifier">exeExtension</span></a></span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Symbolic links</span></span><span>
</span><span id="line-77"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#createFileLink"><span class="hs-identifier">createFileLink</span></a></span><span>
</span><span id="line-78"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#createDirectoryLink"><span class="hs-identifier">createDirectoryLink</span></a></span><span>
</span><span id="line-79"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#removeDirectoryLink"><span class="hs-identifier">removeDirectoryLink</span></a></span><span>
</span><span id="line-80"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#pathIsSymbolicLink"><span class="hs-identifier">pathIsSymbolicLink</span></a></span><span>
</span><span id="line-81"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getSymbolicLinkTarget"><span class="hs-identifier">getSymbolicLinkTarget</span></a></span><span>
</span><span id="line-82"></span><span>
</span><span id="line-83"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Permissions</span></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span>    </span><span class="annot"><span class="hs-comment">-- $permissions</span></span><span>
</span><span id="line-86"></span><span>
</span><span id="line-87"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier">Permissions</span></a></span><span>
</span><span id="line-88"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#emptyPermissions"><span class="hs-identifier">emptyPermissions</span></a></span><span>
</span><span id="line-89"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#readable"><span class="hs-identifier">readable</span></a></span><span>
</span><span id="line-90"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#writable"><span class="hs-identifier">writable</span></a></span><span>
</span><span id="line-91"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#executable"><span class="hs-identifier">executable</span></a></span><span>
</span><span id="line-92"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#searchable"><span class="hs-identifier">searchable</span></a></span><span>
</span><span id="line-93"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#setOwnerReadable"><span class="hs-identifier">setOwnerReadable</span></a></span><span>
</span><span id="line-94"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#setOwnerWritable"><span class="hs-identifier">setOwnerWritable</span></a></span><span>
</span><span id="line-95"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#setOwnerExecutable"><span class="hs-identifier">setOwnerExecutable</span></a></span><span>
</span><span id="line-96"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#setOwnerSearchable"><span class="hs-identifier">setOwnerSearchable</span></a></span><span>
</span><span id="line-97"></span><span>
</span><span id="line-98"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getPermissions"><span class="hs-identifier">getPermissions</span></a></span><span>
</span><span id="line-99"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#setPermissions"><span class="hs-identifier">setPermissions</span></a></span><span>
</span><span id="line-100"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#copyPermissions"><span class="hs-identifier">copyPermissions</span></a></span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Timestamps</span></span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getAccessTime"><span class="hs-identifier">getAccessTime</span></a></span><span>
</span><span id="line-105"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#getModificationTime"><span class="hs-identifier">getModificationTime</span></a></span><span>
</span><span id="line-106"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#setAccessTime"><span class="hs-identifier">setAccessTime</span></a></span><span>
</span><span id="line-107"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#setModificationTime"><span class="hs-identifier">setModificationTime</span></a></span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Deprecated</span></span><span>
</span><span id="line-110"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Directory.html#isSymbolicLink"><span class="hs-identifier">isSymbolicLink</span></a></span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span>   </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-113"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-114"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Directory.Internal.html"><span class="hs-identifier">System.Directory.Internal</span></a></span><span>
</span><span id="line-115"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Directory.Internal.Prelude.html"><span class="hs-identifier">System.Directory.Internal.Prelude</span></a></span><span>
</span><span id="line-116"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.html#"><span class="hs-identifier">System.FilePath</span></a></span><span>
</span><span id="line-117"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#%3C.%3E"><span class="hs-operator">(&lt;.&gt;)</span></a></span><span>
</span><span id="line-118"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator">(&lt;/&gt;)</span></a></span><span>
</span><span id="line-119"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#addTrailingPathSeparator"><span class="hs-identifier">addTrailingPathSeparator</span></a></span><span>
</span><span id="line-120"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#dropTrailingPathSeparator"><span class="hs-identifier">dropTrailingPathSeparator</span></a></span><span>
</span><span id="line-121"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#hasTrailingPathSeparator"><span class="hs-identifier">hasTrailingPathSeparator</span></a></span><span>
</span><span id="line-122"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#isAbsolute"><span class="hs-identifier">isAbsolute</span></a></span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#joinPath"><span class="hs-identifier">joinPath</span></a></span><span>
</span><span id="line-124"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#makeRelative"><span class="hs-identifier">makeRelative</span></a></span><span>
</span><span id="line-125"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#splitDirectories"><span class="hs-identifier">splitDirectories</span></a></span><span>
</span><span id="line-126"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#splitSearchPath"><span class="hs-identifier">splitSearchPath</span></a></span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#takeDirectory"><span class="hs-identifier">takeDirectory</span></a></span><span>
</span><span id="line-128"></span><span>  </span><span class="hs-special">)</span><span>
</span><span id="line-129"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../time/src/Data.Time.html#"><span class="hs-identifier">Data.Time</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../time/src/Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier">UTCTime</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-130"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../time/src/Data.Time.Clock.POSIX.html#"><span class="hs-identifier">Data.Time.Clock.POSIX</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../time/src/Data.Time.Clock.POSIX.html#utcTimeToPOSIXSeconds"><span class="hs-identifier">utcTimeToPOSIXSeconds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-comment">{- $intro
A directory contains a series of entries, each of which is a named
reference to a file system object (file, directory etc.).  Some
entries may be hidden, inaccessible, or have some administrative
function (e.g. @.@ or @..@ under
&lt;http://www.opengroup.org/onlinepubs/009695399 POSIX&gt;), but in
this standard all such entries are considered to form part of the
directory contents. Entries in sub-directories are not, however,
considered to form part of the directory contents.

Each file system object is referenced by a /path/.  There is
normally at least one absolute path to each file system object.  In
some operating systems, it may also be possible to have paths which
are relative to the current directory.

Unless otherwise documented:

* 'IO' operations in this package may throw any 'IOError'.  No other types of
  exceptions shall be thrown.

* The list of possible 'IOErrorType's in the API documentation is not
  exhaustive.  The full list may vary by platform and/or evolve over time.

-}</span><span>
</span><span id="line-156"></span><span>
</span><span id="line-157"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-158"></span><span class="hs-comment">-- Permissions</span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="hs-comment">{- $permissions

directory offers a limited (and quirky) interface for reading and setting file
and directory permissions; see 'getPermissions' and 'setPermissions' for a
discussion of their limitations.  Because permissions are very difficult to
implement portably across different platforms, users who wish to do more
sophisticated things with permissions are advised to use other,
platform-specific libraries instead.  For example, if you are only interested
in permissions on POSIX-like platforms,
&lt;https://hackage.haskell.org/package/unix/docs/System-Posix-Files.html unix&gt;
offers much more flexibility.

 The 'Permissions' type is used to record whether certain operations are
 permissible on a file\/directory. 'getPermissions' and 'setPermissions'
 get and set these permissions, respectively. Permissions apply both to
 files and directories. For directories, the executable field will be
 'False', and for files the searchable field will be 'False'. Note that
 directories may be searchable without being readable, if permission has
 been given to use them as part of a path, but not to examine the
 directory contents.

Note that to change some, but not all permissions, a construct on the following lines must be used.

&gt;  makeReadable f = do
&gt;     p &lt;- getPermissions f
&gt;     setPermissions f (p {readable = True})

-}</span><span>
</span><span id="line-188"></span><span>
</span><span id="line-189"></span><span class="annot"><a href="System.Directory.html#emptyPermissions"><span class="hs-identifier hs-type">emptyPermissions</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span>
</span><span id="line-190"></span><span id="emptyPermissions"><span class="annot"><span class="annottext">emptyPermissions :: Permissions
</span><a href="System.Directory.html#emptyPermissions"><span class="hs-identifier hs-var hs-var">emptyPermissions</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Permissions :: Bool -&gt; Bool -&gt; Bool -&gt; Bool -&gt; Permissions
</span><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-191"></span><span>                       </span><span class="annot"><span class="annottext">readable :: Bool
</span><a href="System.Directory.Internal.Common.html#readable"><span class="hs-identifier hs-var">readable</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-192"></span><span>                       </span><span class="annot"><span class="annottext">writable :: Bool
</span><a href="System.Directory.Internal.Common.html#writable"><span class="hs-identifier hs-var">writable</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-193"></span><span>                       </span><span class="annot"><span class="annottext">executable :: Bool
</span><a href="System.Directory.Internal.Common.html#executable"><span class="hs-identifier hs-var">executable</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span>
</span><span id="line-194"></span><span>                       </span><span class="annot"><span class="annottext">searchable :: Bool
</span><a href="System.Directory.Internal.Common.html#searchable"><span class="hs-identifier hs-var">searchable</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-195"></span><span>                   </span><span class="hs-special">}</span><span>
</span><span id="line-196"></span><span>
</span><span id="line-197"></span><span class="annot"><a href="System.Directory.html#setOwnerReadable"><span class="hs-identifier hs-type">setOwnerReadable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span>
</span><span id="line-198"></span><span id="setOwnerReadable"><span class="annot"><span class="annottext">setOwnerReadable :: Bool -&gt; Permissions -&gt; Permissions
</span><a href="System.Directory.html#setOwnerReadable"><span class="hs-identifier hs-var hs-var">setOwnerReadable</span></a></span></span><span> </span><span id="local-6989586621679048881"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048881"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621679048880"><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048880"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048880"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">readable :: Bool
</span><a href="System.Directory.Internal.Common.html#readable"><span class="hs-identifier hs-var">readable</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048881"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-199"></span><span>
</span><span id="line-200"></span><span class="annot"><a href="System.Directory.html#setOwnerWritable"><span class="hs-identifier hs-type">setOwnerWritable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span>
</span><span id="line-201"></span><span id="setOwnerWritable"><span class="annot"><span class="annottext">setOwnerWritable :: Bool -&gt; Permissions -&gt; Permissions
</span><a href="System.Directory.html#setOwnerWritable"><span class="hs-identifier hs-var hs-var">setOwnerWritable</span></a></span></span><span> </span><span id="local-6989586621679048879"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048879"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621679048878"><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048878"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048878"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">writable :: Bool
</span><a href="System.Directory.Internal.Common.html#writable"><span class="hs-identifier hs-var">writable</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048879"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-202"></span><span>
</span><span id="line-203"></span><span class="annot"><a href="System.Directory.html#setOwnerExecutable"><span class="hs-identifier hs-type">setOwnerExecutable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span>
</span><span id="line-204"></span><span id="setOwnerExecutable"><span class="annot"><span class="annottext">setOwnerExecutable :: Bool -&gt; Permissions -&gt; Permissions
</span><a href="System.Directory.html#setOwnerExecutable"><span class="hs-identifier hs-var hs-var">setOwnerExecutable</span></a></span></span><span> </span><span id="local-6989586621679048877"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048877"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621679048876"><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048876"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048876"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">executable :: Bool
</span><a href="System.Directory.Internal.Common.html#executable"><span class="hs-identifier hs-var">executable</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048877"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span class="annot"><a href="System.Directory.html#setOwnerSearchable"><span class="hs-identifier hs-type">setOwnerSearchable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span>
</span><span id="line-207"></span><span id="setOwnerSearchable"><span class="annot"><span class="annottext">setOwnerSearchable :: Bool -&gt; Permissions -&gt; Permissions
</span><a href="System.Directory.html#setOwnerSearchable"><span class="hs-identifier hs-var hs-var">setOwnerSearchable</span></a></span></span><span> </span><span id="local-6989586621679048875"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048875"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621679048874"><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048874"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048874"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">searchable :: Bool
</span><a href="System.Directory.Internal.Common.html#searchable"><span class="hs-identifier hs-var">searchable</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048875"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-208"></span><span>
</span><span id="line-209"></span><span class="hs-comment">-- | Get the permissions of a file or directory.</span><span>
</span><span id="line-210"></span><span class="hs-comment">--</span><span>
</span><span id="line-211"></span><span class="hs-comment">-- On Windows, the 'writable' permission corresponds to the &quot;read-only&quot;</span><span>
</span><span id="line-212"></span><span class="hs-comment">-- attribute.  The 'executable' permission is set if the file extension is of</span><span>
</span><span id="line-213"></span><span class="hs-comment">-- an executable file type.  The 'readable' permission is always set.</span><span>
</span><span id="line-214"></span><span class="hs-comment">--</span><span>
</span><span id="line-215"></span><span class="hs-comment">-- On POSIX systems, this returns the result of @access@.</span><span>
</span><span id="line-216"></span><span class="hs-comment">--</span><span>
</span><span id="line-217"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-218"></span><span class="hs-comment">--</span><span>
</span><span id="line-219"></span><span class="hs-comment">-- * 'isPermissionError' if the user is not permitted to access the</span><span>
</span><span id="line-220"></span><span class="hs-comment">--   permissions, or</span><span>
</span><span id="line-221"></span><span class="hs-comment">--</span><span>
</span><span id="line-222"></span><span class="hs-comment">-- * 'isDoesNotExistError' if the file or directory does not exist.</span><span>
</span><span id="line-223"></span><span class="annot"><a href="System.Directory.html#getPermissions"><span class="hs-identifier hs-type">getPermissions</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span>
</span><span id="line-224"></span><span id="getPermissions"><span class="annot"><span class="annottext">getPermissions :: FilePath -&gt; IO Permissions
</span><a href="System.Directory.html#getPermissions"><span class="hs-identifier hs-var hs-var">getPermissions</span></a></span></span><span> </span><span id="local-6989586621679048873"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048873"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-225"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getPermissions&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO Permissions -&gt; IO Permissions
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-226"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO Permissions
</span><a href="System.Directory.Internal.Windows.html#getAccessPermissions"><span class="hs-identifier hs-var">getAccessPermissions</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="System.Directory.Internal.Common.html#emptyToCurDir"><span class="hs-identifier hs-var">emptyToCurDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048873"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-227"></span><span>
</span><span id="line-228"></span><span class="hs-comment">-- | Set the permissions of a file or directory.</span><span>
</span><span id="line-229"></span><span class="hs-comment">--</span><span>
</span><span id="line-230"></span><span class="hs-comment">-- On Windows, this is only capable of changing the 'writable' permission,</span><span>
</span><span id="line-231"></span><span class="hs-comment">-- which corresponds to the &quot;read-only&quot; attribute.  Changing the other</span><span>
</span><span id="line-232"></span><span class="hs-comment">-- permissions has no effect.</span><span>
</span><span id="line-233"></span><span class="hs-comment">--</span><span>
</span><span id="line-234"></span><span class="hs-comment">-- On POSIX systems, this sets the /owner/ permissions.</span><span>
</span><span id="line-235"></span><span class="hs-comment">--</span><span>
</span><span id="line-236"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-237"></span><span class="hs-comment">--</span><span>
</span><span id="line-238"></span><span class="hs-comment">-- * 'isPermissionError' if the user is not permitted to set the permissions,</span><span>
</span><span id="line-239"></span><span class="hs-comment">--   or</span><span>
</span><span id="line-240"></span><span class="hs-comment">--</span><span>
</span><span id="line-241"></span><span class="hs-comment">-- * 'isDoesNotExistError' if the file or directory does not exist.</span><span>
</span><span id="line-242"></span><span class="annot"><a href="System.Directory.html#setPermissions"><span class="hs-identifier hs-type">setPermissions</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#Permissions"><span class="hs-identifier hs-type">Permissions</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-243"></span><span id="setPermissions"><span class="annot"><span class="annottext">setPermissions :: FilePath -&gt; Permissions -&gt; IO ()
</span><a href="System.Directory.html#setPermissions"><span class="hs-identifier hs-var hs-var">setPermissions</span></a></span></span><span> </span><span id="local-6989586621679048868"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048868"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679048867"><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048867"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-244"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;setPermissions&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-245"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Permissions -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#setAccessPermissions"><span class="hs-identifier hs-var">setAccessPermissions</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="System.Directory.Internal.Common.html#emptyToCurDir"><span class="hs-identifier hs-var">emptyToCurDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048868"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048867"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-246"></span><span>
</span><span id="line-247"></span><span class="hs-comment">-- | Copy the permissions of one file to another.  This reproduces the</span><span>
</span><span id="line-248"></span><span class="hs-comment">-- permissions more accurately than using 'getPermissions' followed by</span><span>
</span><span id="line-249"></span><span class="hs-comment">-- 'setPermissions'.</span><span>
</span><span id="line-250"></span><span class="hs-comment">--</span><span>
</span><span id="line-251"></span><span class="hs-comment">-- On Windows, this copies only the read-only attribute.</span><span>
</span><span id="line-252"></span><span class="hs-comment">--</span><span>
</span><span id="line-253"></span><span class="hs-comment">-- On POSIX systems, this is equivalent to @stat@ followed by @chmod@.</span><span>
</span><span id="line-254"></span><span class="annot"><a href="System.Directory.html#copyPermissions"><span class="hs-identifier hs-type">copyPermissions</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-255"></span><span id="copyPermissions"><span class="annot"><span class="annottext">copyPermissions :: FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#copyPermissions"><span class="hs-identifier hs-var hs-var">copyPermissions</span></a></span></span><span> </span><span id="local-6989586621679048865"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048865"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span id="local-6989586621679048864"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048864"><span class="hs-identifier hs-var">dst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-256"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;copyPermissions&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-257"></span><span>    </span><span id="local-6989586621679048863"><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048863"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getFileMetadata"><span class="hs-identifier hs-var">getFileMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048865"><span class="hs-identifier hs-var">src</span></a></span><span>
</span><span id="line-258"></span><span>    </span><span class="annot"><span class="annottext">Metadata -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#copyPermissionsFromMetadata"><span class="hs-identifier hs-var">copyPermissionsFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048863"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048864"><span class="hs-identifier hs-var">dst</span></a></span><span>
</span><span id="line-259"></span><span>
</span><span id="line-260"></span><span class="annot"><a href="System.Directory.html#copyPermissionsFromMetadata"><span class="hs-identifier hs-type">copyPermissionsFromMetadata</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Directory.Internal.Windows.html#Metadata"><span class="hs-identifier hs-type">Metadata</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-261"></span><span id="copyPermissionsFromMetadata"><span class="annot"><span class="annottext">copyPermissionsFromMetadata :: Metadata -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#copyPermissionsFromMetadata"><span class="hs-identifier hs-var hs-var">copyPermissionsFromMetadata</span></a></span></span><span> </span><span id="local-6989586621679048860"><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048860"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679048859"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048859"><span class="hs-identifier hs-var">dst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-262"></span><span>  </span><span class="hs-comment">-- instead of setFileMode, setFilePermissions is used here</span><span>
</span><span id="line-263"></span><span>  </span><span class="hs-comment">-- this is to retain backward compatibility in copyPermissions</span><span>
</span><span id="line-264"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; Mode -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#setFilePermissions"><span class="hs-identifier hs-var">setFilePermissions</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048859"><span class="hs-identifier hs-var">dst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Metadata -&gt; Mode
</span><a href="System.Directory.Internal.Windows.html#modeFromMetadata"><span class="hs-identifier hs-var">modeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048860"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-265"></span><span>
</span><span id="line-266"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-267"></span><span class="hs-comment">-- Implementation</span><span>
</span><span id="line-268"></span><span>
</span><span id="line-269"></span><span class="hs-comment">{- |@'createDirectory' dir@ creates a new directory @dir@ which is
initially empty, or as near to empty as the operating system
allows.

The operation may fail with:

* 'isPermissionError'
The process has insufficient privileges to perform the operation.
@[EROFS, EACCES]@

* 'isAlreadyExistsError'
The operand refers to a directory that already exists.
@ [EEXIST]@

* @HardwareFault@
A physical I\/O error has occurred.
@[EIO]@

* @InvalidArgument@
The operand is not a valid directory name.
@[ENAMETOOLONG, ELOOP]@

* 'isDoesNotExistError'
There is no path to the directory.
@[ENOENT, ENOTDIR]@

* 'System.IO.isFullError'
Insufficient resources (virtual memory, process file descriptors,
physical disk space, etc.) are available to perform the operation.
@[EDQUOT, ENOSPC, ENOMEM, EMLINK]@

* @InappropriateType@
The path refers to an existing non-directory object.
@[EEXIST]@

-}</span><span>
</span><span id="line-305"></span><span>
</span><span id="line-306"></span><span class="annot"><a href="System.Directory.html#createDirectory"><span class="hs-identifier hs-type">createDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-307"></span><span id="createDirectory"><span class="annot"><span class="annottext">createDirectory :: FilePath -&gt; IO ()
</span><a href="System.Directory.html#createDirectory"><span class="hs-identifier hs-var hs-var">createDirectory</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#createDirectoryInternal"><span class="hs-identifier hs-var">createDirectoryInternal</span></a></span><span>
</span><span id="line-308"></span><span>
</span><span id="line-309"></span><span class="hs-comment">-- | @'createDirectoryIfMissing' parents dir@ creates a new directory</span><span>
</span><span id="line-310"></span><span class="hs-comment">-- @dir@ if it doesn\'t exist. If the first argument is 'True'</span><span>
</span><span id="line-311"></span><span class="hs-comment">-- the function will also create all parent directories if they are missing.</span><span>
</span><span id="line-312"></span><span class="annot"><a href="System.Directory.html#createDirectoryIfMissing"><span class="hs-identifier hs-type">createDirectoryIfMissing</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>     </span><span class="hs-comment">-- ^ Create its parents too?</span><span>
</span><span id="line-313"></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-comment">-- ^ The path to the directory you want to make</span><span>
</span><span id="line-314"></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-315"></span><span id="createDirectoryIfMissing"><span class="annot"><span class="annottext">createDirectoryIfMissing :: Bool -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#createDirectoryIfMissing"><span class="hs-identifier hs-var hs-var">createDirectoryIfMissing</span></a></span></span><span> </span><span id="local-6989586621679048855"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048855"><span class="hs-identifier hs-var">create_parents</span></a></span></span><span> </span><span id="local-6989586621679048854"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048854"><span class="hs-identifier hs-var">path0</span></a></span></span><span>
</span><span id="line-316"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048855"><span class="hs-identifier hs-var">create_parents</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[FilePath] -&gt; IO ()
</span><a href="#local-6989586621679048853"><span class="hs-identifier hs-var">createDirs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; [FilePath]
</span><a href="#local-6989586621679048852"><span class="hs-identifier hs-var">parents</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048854"><span class="hs-identifier hs-var">path0</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-317"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[FilePath] -&gt; IO ()
</span><a href="#local-6989586621679048853"><span class="hs-identifier hs-var">createDirs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; [FilePath] -&gt; [FilePath]
forall a. Int -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; [FilePath]
</span><a href="#local-6989586621679048852"><span class="hs-identifier hs-var">parents</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048854"><span class="hs-identifier hs-var">path0</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-318"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-319"></span><span>    </span><span id="local-6989586621679048852"><span class="annot"><span class="annottext">parents :: FilePath -&gt; [FilePath]
</span><a href="#local-6989586621679048852"><span class="hs-identifier hs-var hs-var">parents</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[FilePath] -&gt; [FilePath]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">([FilePath] -&gt; [FilePath])
-&gt; (FilePath -&gt; [FilePath]) -&gt; FilePath -&gt; [FilePath]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath -&gt; FilePath) -&gt; [FilePath] -&gt; [FilePath]
forall a. (a -&gt; a -&gt; a) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#scanl1"><span class="hs-identifier hs-var">scanl1</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">(&lt;/&gt;)</span></a></span><span> </span><span class="annot"><span class="annottext">([FilePath] -&gt; [FilePath])
-&gt; (FilePath -&gt; [FilePath]) -&gt; FilePath -&gt; [FilePath]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; [FilePath]
</span><a href="../../filepath/src/System.FilePath.Windows.html#splitDirectories"><span class="hs-identifier hs-var">splitDirectories</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; [FilePath])
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; [FilePath]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="System.Directory.Internal.Windows.html#simplify"><span class="hs-identifier hs-var">simplify</span></a></span><span>
</span><span id="line-320"></span><span>
</span><span id="line-321"></span><span>    </span><span id="local-6989586621679048853"><span class="annot"><span class="annottext">createDirs :: [FilePath] -&gt; IO ()
</span><a href="#local-6989586621679048853"><span class="hs-identifier hs-var hs-var">createDirs</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-322"></span><span>    </span><span class="annot"><a href="#local-6989586621679048853"><span class="hs-identifier hs-var">createDirs</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679048844"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048844"><span class="hs-identifier hs-var">dir</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; (IOError -&gt; IO ()) -&gt; IO ()
</span><a href="#local-6989586621679048843"><span class="hs-identifier hs-var">createDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048844"><span class="hs-identifier hs-var">dir</span></a></span><span> </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span>
</span><span id="line-323"></span><span>    </span><span class="annot"><a href="#local-6989586621679048853"><span class="hs-identifier hs-var">createDirs</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679048841"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048841"><span class="hs-identifier hs-var">dir</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679048840"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048840"><span class="hs-identifier hs-var">dirs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-324"></span><span>      </span><span class="annot"><span class="annottext">FilePath -&gt; (IOError -&gt; IO ()) -&gt; IO ()
</span><a href="#local-6989586621679048843"><span class="hs-identifier hs-var">createDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048841"><span class="hs-identifier hs-var">dir</span></a></span><span> </span><span class="annot"><span class="annottext">((IOError -&gt; IO ()) -&gt; IO ()) -&gt; (IOError -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-325"></span><span>        </span><span class="annot"><span class="annottext">[FilePath] -&gt; IO ()
</span><a href="#local-6989586621679048853"><span class="hs-identifier hs-var">createDirs</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048840"><span class="hs-identifier hs-var">dirs</span></a></span><span>
</span><span id="line-326"></span><span>        </span><span class="annot"><span class="annottext">FilePath -&gt; (IOError -&gt; IO ()) -&gt; IO ()
</span><a href="#local-6989586621679048843"><span class="hs-identifier hs-var">createDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048841"><span class="hs-identifier hs-var">dir</span></a></span><span> </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span>
</span><span id="line-327"></span><span>
</span><span id="line-328"></span><span>    </span><span id="local-6989586621679048843"><span class="annot"><span class="annottext">createDir :: FilePath -&gt; (IOError -&gt; IO ()) -&gt; IO ()
</span><a href="#local-6989586621679048843"><span class="hs-identifier hs-var hs-var">createDir</span></a></span></span><span> </span><span id="local-6989586621679048834"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048834"><span class="hs-identifier hs-var">dir</span></a></span></span><span> </span><span id="local-6989586621679048833"><span class="annot"><span class="annottext">IOError -&gt; IO ()
</span><a href="#local-6989586621679048833"><span class="hs-identifier hs-var">notExistHandler</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-329"></span><span>      </span><span id="local-6989586621679048832"><span class="annot"><span class="annottext">Either IOError ()
</span><a href="#local-6989586621679048832"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO (Either IOError ())
forall a. IO a -&gt; IO (Either IOError a)
</span><a href="../../base/src/System.IO.Error.html#tryIOError"><span class="hs-identifier hs-var">tryIOError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#createDirectory"><span class="hs-identifier hs-var">createDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048834"><span class="hs-identifier hs-var">dir</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-330"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either IOError ()
</span><a href="#local-6989586621679048832"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-331"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-332"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span>  </span><span id="local-6989586621679048830"><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048830"><span class="hs-identifier hs-var">e</span></a></span></span><span>
</span><span id="line-333"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">IOError -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isDoesNotExistError"><span class="hs-identifier hs-var">isDoesNotExistError</span></a></span><span>  </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048830"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
</span><a href="#local-6989586621679048833"><span class="hs-identifier hs-var">notExistHandler</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048830"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-334"></span><span>          </span><span class="hs-comment">-- createDirectory (and indeed POSIX mkdir) does not distinguish</span><span>
</span><span id="line-335"></span><span>          </span><span class="hs-comment">-- between a dir already existing and a file already existing. So we</span><span>
</span><span id="line-336"></span><span>          </span><span class="hs-comment">-- check for it here. Unfortunately there is a slight race condition</span><span>
</span><span id="line-337"></span><span>          </span><span class="hs-comment">-- here, but we think it is benign. It could report an exeption in</span><span>
</span><span id="line-338"></span><span>          </span><span class="hs-comment">-- the case that the dir did exist but another process deletes the</span><span>
</span><span id="line-339"></span><span>          </span><span class="hs-comment">-- directory and creates a file in its place before we can check</span><span>
</span><span id="line-340"></span><span>          </span><span class="hs-comment">-- that the directory did indeed exist.</span><span>
</span><span id="line-341"></span><span>          </span><span class="hs-comment">-- We also follow this path when we get a permissions error, as</span><span>
</span><span id="line-342"></span><span>          </span><span class="hs-comment">-- trying to create &quot;.&quot; when in the root directory on Windows</span><span>
</span><span id="line-343"></span><span>          </span><span class="hs-comment">-- fails with</span><span>
</span><span id="line-344"></span><span>          </span><span class="hs-comment">--     CreateDirectory &quot;.&quot;: permission denied (Access is denied.)</span><span>
</span><span id="line-345"></span><span>          </span><span class="hs-comment">-- This caused GHCi to crash when loading a module in the root</span><span>
</span><span id="line-346"></span><span>          </span><span class="hs-comment">-- directory.</span><span>
</span><span id="line-347"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">IOError -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isAlreadyExistsError"><span class="hs-identifier hs-var">isAlreadyExistsError</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048830"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-348"></span><span>         </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">IOError -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isPermissionError"><span class="hs-identifier hs-var">isPermissionError</span></a></span><span>    </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048830"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-349"></span><span>              </span><span id="local-6989586621679048825"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048825"><span class="hs-identifier hs-var">canIgnore</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="System.Directory.html#pathIsDirectory"><span class="hs-identifier hs-var">pathIsDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048834"><span class="hs-identifier hs-var">dir</span></a></span><span>
</span><span id="line-350"></span><span>                             </span><span class="annot"><span class="annottext">IO Bool -&gt; (IOError -&gt; IO Bool) -&gt; IO Bool
forall a. IO a -&gt; (IOError -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#catchIOError"><span class="hs-operator hs-var">`catchIOError`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-351"></span><span>                               </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isAlreadyExistsError"><span class="hs-identifier hs-var">isAlreadyExistsError</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048830"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-352"></span><span>              </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048825"><span class="hs-identifier hs-var">canIgnore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048830"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-353"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048830"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-354"></span><span>
</span><span id="line-355"></span><span>
</span><span id="line-356"></span><span class="hs-comment">{- | @'removeDirectory' dir@ removes an existing directory /dir/.  The
implementation may specify additional constraints which must be
satisfied before a directory can be removed (e.g. the directory has to
be empty, or may not be in use by other processes).  It is not legal
for an implementation to partially remove a directory unless the
entire directory is removed. A conformant implementation need not
support directory removal in all situations (e.g. removal of the root
directory).

The operation may fail with:

* @HardwareFault@
A physical I\/O error has occurred.
@[EIO]@

* @InvalidArgument@
The operand is not a valid directory name.
@[ENAMETOOLONG, ELOOP]@

* 'isDoesNotExistError'
The directory does not exist.
@[ENOENT, ENOTDIR]@

* 'isPermissionError'
The process has insufficient privileges to perform the operation.
@[EROFS, EACCES, EPERM]@

* @UnsatisfiedConstraints@
Implementation-dependent constraints are not satisfied.
@[EBUSY, ENOTEMPTY, EEXIST]@

* @UnsupportedOperation@
The implementation does not support removal in this situation.
@[EINVAL]@

* @InappropriateType@
The operand refers to an existing non-directory object.
@[ENOTDIR]@

-}</span><span>
</span><span id="line-396"></span><span>
</span><span id="line-397"></span><span class="annot"><a href="System.Directory.html#removeDirectory"><span class="hs-identifier hs-type">removeDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-398"></span><span id="removeDirectory"><span class="annot"><span class="annottext">removeDirectory :: FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeDirectory"><span class="hs-identifier hs-var hs-var">removeDirectory</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#removePathInternal"><span class="hs-identifier hs-var">removePathInternal</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-399"></span><span>
</span><span id="line-400"></span><span class="hs-comment">-- | @'removeDirectoryRecursive' dir@ removes an existing directory /dir/</span><span>
</span><span id="line-401"></span><span class="hs-comment">-- together with its contents and subdirectories. Within this directory,</span><span>
</span><span id="line-402"></span><span class="hs-comment">-- symbolic links are removed without affecting their targets.</span><span>
</span><span id="line-403"></span><span class="hs-comment">--</span><span>
</span><span id="line-404"></span><span class="hs-comment">-- On Windows, the operation fails if /dir/ is a directory symbolic link.</span><span>
</span><span id="line-405"></span><span class="hs-comment">--</span><span>
</span><span id="line-406"></span><span class="hs-comment">-- This operation is reported to be flaky on Windows so retry logic may </span><span>
</span><span id="line-407"></span><span class="hs-comment">-- be advisable. See: https://github.com/haskell/directory/pull/108</span><span>
</span><span id="line-408"></span><span class="annot"><a href="System.Directory.html#removeDirectoryRecursive"><span class="hs-identifier hs-type">removeDirectoryRecursive</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-409"></span><span id="removeDirectoryRecursive"><span class="annot"><span class="annottext">removeDirectoryRecursive :: FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeDirectoryRecursive"><span class="hs-identifier hs-var hs-var">removeDirectoryRecursive</span></a></span></span><span> </span><span id="local-6989586621679048820"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048820"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-410"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;removeDirectoryRecursive&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-411"></span><span>    </span><span id="local-6989586621679048819"><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048819"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getSymbolicLinkMetadata"><span class="hs-identifier hs-var">getSymbolicLinkMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048820"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-412"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Metadata -&gt; FileType
</span><a href="System.Directory.Internal.Windows.html#fileTypeFromMetadata"><span class="hs-identifier hs-var">fileTypeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048819"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-413"></span><span>      </span><span class="annot"><span class="annottext">FileType
</span><a href="System.Directory.Internal.Common.html#Directory"><span class="hs-identifier hs-var">Directory</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-414"></span><span>        </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeContentsRecursive"><span class="hs-identifier hs-var">removeContentsRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048820"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-415"></span><span>      </span><span class="annot"><span class="annottext">FileType
</span><a href="System.Directory.Internal.Common.html#DirectoryLink"><span class="hs-identifier hs-var">DirectoryLink</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-416"></span><span>        </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048813"><span class="hs-identifier hs-var">err</span></a></span><span> </span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#ioeSetErrorString"><span class="hs-operator hs-var">`ioeSetErrorString`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;is a directory symbolic link&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-417"></span><span>      </span><span class="annot"><span class="annottext">FileType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-418"></span><span>        </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048813"><span class="hs-identifier hs-var">err</span></a></span><span> </span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#ioeSetErrorString"><span class="hs-operator hs-var">`ioeSetErrorString`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;not a directory&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-419"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679048813"><span class="annot"><span class="annottext">err :: IOError
</span><a href="#local-6989586621679048813"><span class="hs-identifier hs-var hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOErrorType
-&gt; FilePath -&gt; Maybe Handle -&gt; Maybe FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#mkIOError"><span class="hs-identifier hs-var">mkIOError</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#InappropriateType"><span class="hs-identifier hs-var">InappropriateType</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; Maybe FilePath
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048820"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span class="hs-comment">-- | @removePathRecursive path@ removes an existing file or directory at</span><span>
</span><span id="line-422"></span><span class="hs-comment">-- /path/ together with its contents and subdirectories. Symbolic links are</span><span>
</span><span id="line-423"></span><span class="hs-comment">-- removed without affecting their the targets.</span><span>
</span><span id="line-424"></span><span class="hs-comment">--</span><span>
</span><span id="line-425"></span><span class="hs-comment">-- This operation is reported to be flaky on Windows so retry logic may </span><span>
</span><span id="line-426"></span><span class="hs-comment">-- be advisable. See: https://github.com/haskell/directory/pull/108</span><span>
</span><span id="line-427"></span><span class="annot"><a href="System.Directory.html#removePathRecursive"><span class="hs-identifier hs-type">removePathRecursive</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-428"></span><span id="removePathRecursive"><span class="annot"><span class="annottext">removePathRecursive :: FilePath -&gt; IO ()
</span><a href="System.Directory.html#removePathRecursive"><span class="hs-identifier hs-var hs-var">removePathRecursive</span></a></span></span><span> </span><span id="local-6989586621679048808"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048808"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-429"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;removePathRecursive&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-430"></span><span>    </span><span id="local-6989586621679048807"><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048807"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getSymbolicLinkMetadata"><span class="hs-identifier hs-var">getSymbolicLinkMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048808"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-431"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Metadata -&gt; FileType
</span><a href="System.Directory.Internal.Windows.html#fileTypeFromMetadata"><span class="hs-identifier hs-var">fileTypeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048807"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-432"></span><span>      </span><span class="annot"><span class="annottext">FileType
</span><a href="System.Directory.Internal.Common.html#Directory"><span class="hs-identifier hs-var">Directory</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeContentsRecursive"><span class="hs-identifier hs-var">removeContentsRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048808"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-433"></span><span>      </span><span class="annot"><span class="annottext">FileType
</span><a href="System.Directory.Internal.Common.html#DirectoryLink"><span class="hs-identifier hs-var">DirectoryLink</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeDirectory"><span class="hs-identifier hs-var">removeDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048808"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-434"></span><span>      </span><span class="annot"><span class="annottext">FileType
</span><span class="hs-identifier">_</span></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeFile"><span class="hs-identifier hs-var">removeFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048808"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-435"></span><span>
</span><span id="line-436"></span><span class="hs-comment">-- | @removeContentsRecursive dir@ removes the contents of the directory</span><span>
</span><span id="line-437"></span><span class="hs-comment">-- /dir/ recursively. Symbolic links are removed without affecting their the</span><span>
</span><span id="line-438"></span><span class="hs-comment">-- targets.</span><span>
</span><span id="line-439"></span><span class="hs-comment">--</span><span>
</span><span id="line-440"></span><span class="hs-comment">-- This operation is reported to be flaky on Windows so retry logic may </span><span>
</span><span id="line-441"></span><span class="hs-comment">-- be advisable. See: https://github.com/haskell/directory/pull/108</span><span>
</span><span id="line-442"></span><span class="annot"><a href="System.Directory.html#removeContentsRecursive"><span class="hs-identifier hs-type">removeContentsRecursive</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-443"></span><span id="removeContentsRecursive"><span class="annot"><span class="annottext">removeContentsRecursive :: FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeContentsRecursive"><span class="hs-identifier hs-var hs-var">removeContentsRecursive</span></a></span></span><span> </span><span id="local-6989586621679048806"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048806"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-444"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;removeContentsRecursive&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-445"></span><span>    </span><span id="local-6989586621679048805"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048805"><span class="hs-identifier hs-var">cont</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#listDirectory"><span class="hs-identifier hs-var">listDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048806"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-446"></span><span>    </span><span class="annot"><span class="annottext">(FilePath -&gt; IO ()) -&gt; [FilePath] -&gt; IO ()
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Foldable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f ()
</span><a href="../../base/src/Data.Foldable.html#traverse_"><span class="hs-identifier hs-var">traverse_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removePathRecursive"><span class="hs-identifier hs-var">removePathRecursive</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048806"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048803"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679048803"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048803"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048805"><span class="hs-identifier hs-var">cont</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-447"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeDirectory"><span class="hs-identifier hs-var">removeDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048806"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-448"></span><span>
</span><span id="line-449"></span><span class="hs-comment">-- | Removes a file or directory at /path/ together with its contents and</span><span>
</span><span id="line-450"></span><span class="hs-comment">-- subdirectories. Symbolic links are removed without affecting their</span><span>
</span><span id="line-451"></span><span class="hs-comment">-- targets. If the path does not exist, nothing happens.</span><span>
</span><span id="line-452"></span><span class="hs-comment">--</span><span>
</span><span id="line-453"></span><span class="hs-comment">-- Unlike other removal functions, this function will also attempt to delete</span><span>
</span><span id="line-454"></span><span class="hs-comment">-- files marked as read-only or otherwise made unremovable due to permissions.</span><span>
</span><span id="line-455"></span><span class="hs-comment">-- As a result, if the removal is incomplete, the permissions or attributes on</span><span>
</span><span id="line-456"></span><span class="hs-comment">-- the remaining files may be altered.  If there are hard links in the</span><span>
</span><span id="line-457"></span><span class="hs-comment">-- directory, then permissions on all related hard links may be altered.</span><span>
</span><span id="line-458"></span><span class="hs-comment">--</span><span>
</span><span id="line-459"></span><span class="hs-comment">-- If an entry within the directory vanishes while @removePathForcibly@ is</span><span>
</span><span id="line-460"></span><span class="hs-comment">-- running, it is silently ignored.</span><span>
</span><span id="line-461"></span><span class="hs-comment">--</span><span>
</span><span id="line-462"></span><span class="hs-comment">-- If an exception occurs while removing an entry, @removePathForcibly@ will</span><span>
</span><span id="line-463"></span><span class="hs-comment">-- still try to remove as many entries as it can before failing with an</span><span>
</span><span id="line-464"></span><span class="hs-comment">-- exception.  The first exception that it encountered is re-thrown.</span><span>
</span><span id="line-465"></span><span class="hs-comment">--</span><span>
</span><span id="line-466"></span><span class="hs-comment">-- @since 1.2.7.0</span><span>
</span><span id="line-467"></span><span class="annot"><a href="System.Directory.html#removePathForcibly"><span class="hs-identifier hs-type">removePathForcibly</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-468"></span><span id="removePathForcibly"><span class="annot"><span class="annottext">removePathForcibly :: FilePath -&gt; IO ()
</span><a href="System.Directory.html#removePathForcibly"><span class="hs-identifier hs-var hs-var">removePathForcibly</span></a></span></span><span> </span><span id="local-6989586621679048802"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048802"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-469"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;removePathForcibly&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-470"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="#local-6989586621679048801"><span class="hs-identifier hs-var">makeRemovable</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048802"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; (IOError -&gt; IO ()) -&gt; IO ()
forall a. IO a -&gt; (IOError -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#catchIOError"><span class="hs-operator hs-var">`catchIOError`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-471"></span><span>    </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="#local-6989586621679048800"><span class="hs-identifier hs-var">ignoreDoesNotExistError</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-472"></span><span>      </span><span id="local-6989586621679048799"><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048799"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getSymbolicLinkMetadata"><span class="hs-identifier hs-var">getSymbolicLinkMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048802"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-473"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Metadata -&gt; FileType
</span><a href="System.Directory.Internal.Windows.html#fileTypeFromMetadata"><span class="hs-identifier hs-var">fileTypeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048799"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-474"></span><span>        </span><span class="annot"><span class="annottext">FileType
</span><a href="System.Directory.Internal.Common.html#DirectoryLink"><span class="hs-identifier hs-var">DirectoryLink</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeDirectory"><span class="hs-identifier hs-var">removeDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048802"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-475"></span><span>        </span><span class="annot"><span class="annottext">FileType
</span><a href="System.Directory.Internal.Common.html#Directory"><span class="hs-identifier hs-var">Directory</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-476"></span><span>          </span><span id="local-6989586621679048798"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048798"><span class="hs-identifier hs-var">names</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#listDirectory"><span class="hs-identifier hs-var">listDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048802"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-477"></span><span>          </span><span class="annot"><span class="annottext">[IO ()] -&gt; IO ()
</span><a href="System.Directory.Internal.Common.html#sequenceWithIOErrors_"><span class="hs-identifier hs-var">sequenceWithIOErrors_</span></a></span><span> </span><span class="annot"><span class="annottext">([IO ()] -&gt; IO ()) -&gt; [IO ()] -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-478"></span><span>            </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removePathForcibly"><span class="hs-identifier hs-var">removePathForcibly</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048802"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048796"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679048796"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048796"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048798"><span class="hs-identifier hs-var">names</span></a></span><span> </span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[IO ()] -&gt; [IO ()] -&gt; [IO ()]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-479"></span><span>            </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeDirectory"><span class="hs-identifier hs-var">removeDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048802"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-480"></span><span>        </span><span class="annot"><span class="annottext">FileType
</span><span class="hs-identifier">_</span></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeFile"><span class="hs-identifier hs-var">removeFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048802"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-481"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-482"></span><span>
</span><span id="line-483"></span><span>    </span><span class="annot"><a href="#local-6989586621679048800"><span class="hs-identifier hs-type">ignoreDoesNotExistError</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-484"></span><span>    </span><span id="local-6989586621679048800"><span class="annot"><span class="annottext">ignoreDoesNotExistError :: IO () -&gt; IO ()
</span><a href="#local-6989586621679048800"><span class="hs-identifier hs-var hs-var">ignoreDoesNotExistError</span></a></span></span><span> </span><span id="local-6989586621679048795"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048795"><span class="hs-identifier hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-485"></span><span>      </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO (Either IOError ()) -&gt; IO ()
forall (f :: * -&gt; *) a b. Functor f =&gt; a -&gt; f b -&gt; f a
</span><a href="../../base/src/GHC.Base.html#%3C%24"><span class="hs-operator hs-var">&lt;$</span></a></span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; Bool) -&gt; IO () -&gt; IO (Either IOError ())
forall a. (IOError -&gt; Bool) -&gt; IO a -&gt; IO (Either IOError a)
</span><a href="System.Directory.Internal.Common.html#tryIOErrorType"><span class="hs-identifier hs-var">tryIOErrorType</span></a></span><span> </span><span class="annot"><span class="annottext">IOError -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isDoesNotExistError"><span class="hs-identifier hs-var">isDoesNotExistError</span></a></span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679048795"><span class="hs-identifier hs-var">action</span></a></span><span>
</span><span id="line-486"></span><span>
</span><span id="line-487"></span><span>    </span><span class="annot"><a href="#local-6989586621679048801"><span class="hs-identifier hs-type">makeRemovable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-488"></span><span>    </span><span id="local-6989586621679048801"><span class="annot"><span class="annottext">makeRemovable :: FilePath -&gt; IO ()
</span><a href="#local-6989586621679048801"><span class="hs-identifier hs-var hs-var">makeRemovable</span></a></span></span><span> </span><span id="local-6989586621679048792"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048792"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-489"></span><span>      </span><span id="local-6989586621679048791"><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048791"><span class="hs-identifier hs-var">perms</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Permissions
</span><a href="System.Directory.html#getPermissions"><span class="hs-identifier hs-var">getPermissions</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048792"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-490"></span><span>      </span><span class="annot"><span class="annottext">FilePath -&gt; Permissions -&gt; IO ()
</span><a href="System.Directory.html#setPermissions"><span class="hs-identifier hs-var">setPermissions</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048802"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">Permissions
</span><a href="#local-6989586621679048791"><span class="hs-identifier hs-var">perms</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">readable :: Bool
</span><a href="System.Directory.Internal.Common.html#readable"><span class="hs-identifier hs-var">readable</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-491"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">searchable :: Bool
</span><a href="System.Directory.Internal.Common.html#searchable"><span class="hs-identifier hs-var">searchable</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-492"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">writable :: Bool
</span><a href="System.Directory.Internal.Common.html#writable"><span class="hs-identifier hs-var">writable</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-493"></span><span>
</span><span id="line-494"></span><span class="hs-comment">{- |'removeFile' /file/ removes the directory entry for an existing file
/file/, where /file/ is not itself a directory. The
implementation may specify additional constraints which must be
satisfied before a file can be removed (e.g. the file may not be in
use by other processes).

The operation may fail with:

* @HardwareFault@
A physical I\/O error has occurred.
@[EIO]@

* @InvalidArgument@
The operand is not a valid file name.
@[ENAMETOOLONG, ELOOP]@

* 'isDoesNotExistError'
The file does not exist.
@[ENOENT, ENOTDIR]@

* 'isPermissionError'
The process has insufficient privileges to perform the operation.
@[EROFS, EACCES, EPERM]@

* @UnsatisfiedConstraints@
Implementation-dependent constraints are not satisfied.
@[EBUSY]@

* @InappropriateType@
The operand refers to an existing directory.
@[EPERM, EINVAL]@

-}</span><span>
</span><span id="line-527"></span><span>
</span><span id="line-528"></span><span class="annot"><a href="System.Directory.html#removeFile"><span class="hs-identifier hs-type">removeFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-529"></span><span id="removeFile"><span class="annot"><span class="annottext">removeFile :: FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeFile"><span class="hs-identifier hs-var hs-var">removeFile</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#removePathInternal"><span class="hs-identifier hs-var">removePathInternal</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-530"></span><span>
</span><span id="line-531"></span><span class="hs-comment">{- |@'renameDirectory' old new@ changes the name of an existing
directory from /old/ to /new/.  If the /new/ directory
already exists, it is atomically replaced by the /old/ directory.
If the /new/ directory is neither the /old/ directory nor an
alias of the /old/ directory, it is removed as if by
'removeDirectory'.  A conformant implementation need not support
renaming directories in all situations (e.g. renaming to an existing
directory, or across different physical devices), but the constraints
must be documented.

On Win32 platforms, @renameDirectory@ fails if the /new/ directory already
exists.

The operation may fail with:

* @HardwareFault@
A physical I\/O error has occurred.
@[EIO]@

* @InvalidArgument@
Either operand is not a valid directory name.
@[ENAMETOOLONG, ELOOP]@

* 'isDoesNotExistError'
The original directory does not exist, or there is no path to the target.
@[ENOENT, ENOTDIR]@

* 'isPermissionError'
The process has insufficient privileges to perform the operation.
@[EROFS, EACCES, EPERM]@

* 'System.IO.isFullError'
Insufficient resources are available to perform the operation.
@[EDQUOT, ENOSPC, ENOMEM, EMLINK]@

* @UnsatisfiedConstraints@
Implementation-dependent constraints are not satisfied.
@[EBUSY, ENOTEMPTY, EEXIST]@

* @UnsupportedOperation@
The implementation does not support renaming in this situation.
@[EINVAL, EXDEV]@

* @InappropriateType@
Either path refers to an existing non-directory object.
@[ENOTDIR, EISDIR]@

-}</span><span>
</span><span id="line-579"></span><span>
</span><span id="line-580"></span><span class="annot"><a href="System.Directory.html#renameDirectory"><span class="hs-identifier hs-type">renameDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-581"></span><span id="renameDirectory"><span class="annot"><span class="annottext">renameDirectory :: FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#renameDirectory"><span class="hs-identifier hs-var hs-var">renameDirectory</span></a></span></span><span> </span><span id="local-6989586621679048790"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048790"><span class="hs-identifier hs-var">opath</span></a></span></span><span> </span><span id="local-6989586621679048789"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048789"><span class="hs-identifier hs-var">npath</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-582"></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;renameDirectory&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-583"></span><span>     </span><span class="hs-comment">-- XXX this test isn't performed atomically with the following rename</span><span>
</span><span id="line-584"></span><span>     </span><span id="local-6989586621679048788"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048788"><span class="hs-identifier hs-var">isDir</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="System.Directory.html#pathIsDirectory"><span class="hs-identifier hs-var">pathIsDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048790"><span class="hs-identifier hs-var">opath</span></a></span><span>
</span><span id="line-585"></span><span>     </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048788"><span class="hs-identifier hs-var">isDir</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-586"></span><span>       </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IO ()) -&gt; (IOError -&gt; IOError) -&gt; IOError -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#ioeSetErrorString"><span class="hs-operator hs-var">`ioeSetErrorString`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;not a directory&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IO ()) -&gt; IOError -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-587"></span><span>         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOErrorType
-&gt; FilePath -&gt; Maybe Handle -&gt; Maybe FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#mkIOError"><span class="hs-identifier hs-var">mkIOError</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#InappropriateType"><span class="hs-identifier hs-var">InappropriateType</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;renameDirectory&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; Maybe FilePath
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048790"><span class="hs-identifier hs-var">opath</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-588"></span><span>     </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#renamePath"><span class="hs-identifier hs-var">renamePath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048790"><span class="hs-identifier hs-var">opath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048789"><span class="hs-identifier hs-var">npath</span></a></span><span>
</span><span id="line-589"></span><span>
</span><span id="line-590"></span><span class="hs-comment">{- |@'renameFile' old new@ changes the name of an existing file system
object from /old/ to /new/.  If the /new/ object already exists, it is
replaced by the /old/ object.  Neither path may refer to an existing
directory.  A conformant implementation need not support renaming files
in all situations (e.g. renaming across different physical devices), but
the constraints must be documented.

On Windows, this calls @MoveFileEx@ with @MOVEFILE_REPLACE_EXISTING@ set,
which is not guaranteed to be atomic
(&lt;https://github.com/haskell/directory/issues/109&gt;).

On other platforms, this operation is atomic.

The operation may fail with:

* @HardwareFault@
A physical I\/O error has occurred.
@[EIO]@

* @InvalidArgument@
Either operand is not a valid file name.
@[ENAMETOOLONG, ELOOP]@

* 'isDoesNotExistError'
The original file does not exist, or there is no path to the target.
@[ENOENT, ENOTDIR]@

* 'isPermissionError'
The process has insufficient privileges to perform the operation.
@[EROFS, EACCES, EPERM]@

* 'System.IO.isFullError'
Insufficient resources are available to perform the operation.
@[EDQUOT, ENOSPC, ENOMEM, EMLINK]@

* @UnsatisfiedConstraints@
Implementation-dependent constraints are not satisfied.
@[EBUSY]@

* @UnsupportedOperation@
The implementation does not support renaming in this situation.
@[EXDEV]@

* @InappropriateType@
Either path refers to an existing directory.
@[ENOTDIR, EISDIR, EINVAL, EEXIST, ENOTEMPTY]@

-}</span><span>
</span><span id="line-638"></span><span>
</span><span id="line-639"></span><span class="annot"><a href="System.Directory.html#renameFile"><span class="hs-identifier hs-type">renameFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-640"></span><span id="renameFile"><span class="annot"><span class="annottext">renameFile :: FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#renameFile"><span class="hs-identifier hs-var hs-var">renameFile</span></a></span></span><span> </span><span id="local-6989586621679048785"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048785"><span class="hs-identifier hs-var">opath</span></a></span></span><span> </span><span id="local-6989586621679048784"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048784"><span class="hs-identifier hs-var">npath</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-641"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;renameFile&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-642"></span><span>    </span><span class="hs-comment">-- XXX the tests are not performed atomically with the rename</span><span>
</span><span id="line-643"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="#local-6989586621679048783"><span class="hs-identifier hs-var">checkNotDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048785"><span class="hs-identifier hs-var">opath</span></a></span><span>
</span><span id="line-644"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#renamePath"><span class="hs-identifier hs-var">renamePath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048785"><span class="hs-identifier hs-var">opath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048784"><span class="hs-identifier hs-var">npath</span></a></span><span>
</span><span id="line-645"></span><span>      </span><span class="hs-comment">-- The underlying rename implementation can throw odd exceptions when the</span><span>
</span><span id="line-646"></span><span>      </span><span class="hs-comment">-- destination is a directory.  For example, Windows typically throws a</span><span>
</span><span id="line-647"></span><span>      </span><span class="hs-comment">-- permission error, while POSIX systems may throw a resource busy error</span><span>
</span><span id="line-648"></span><span>      </span><span class="hs-comment">-- if one of the paths refers to the current directory.  In these cases,</span><span>
</span><span id="line-649"></span><span>      </span><span class="hs-comment">-- we check if the destination is a directory and, if so, throw an</span><span>
</span><span id="line-650"></span><span>      </span><span class="hs-comment">-- InappropriateType error.</span><span>
</span><span id="line-651"></span><span>      </span><span class="annot"><span class="annottext">IO () -&gt; (IOError -&gt; IO ()) -&gt; IO ()
forall a. IO a -&gt; (IOError -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#catchIOError"><span class="hs-operator hs-var">`catchIOError`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679048782"><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048782"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-652"></span><span>        </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="#local-6989586621679048783"><span class="hs-identifier hs-var">checkNotDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048784"><span class="hs-identifier hs-var">npath</span></a></span><span>
</span><span id="line-653"></span><span>        </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679048782"><span class="hs-identifier hs-var">err</span></a></span><span>
</span><span id="line-654"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679048783"><span class="annot"><span class="annottext">checkNotDir :: FilePath -&gt; IO ()
</span><a href="#local-6989586621679048783"><span class="hs-identifier hs-var hs-var">checkNotDir</span></a></span></span><span> </span><span id="local-6989586621679048777"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048777"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-655"></span><span>          </span><span id="local-6989586621679048776"><span class="annot"><span class="annottext">Either IOError Metadata
</span><a href="#local-6989586621679048776"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO Metadata -&gt; IO (Either IOError Metadata)
forall a. IO a -&gt; IO (Either IOError a)
</span><a href="../../base/src/System.IO.Error.html#tryIOError"><span class="hs-identifier hs-var">tryIOError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getSymbolicLinkMetadata"><span class="hs-identifier hs-var">getSymbolicLinkMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048777"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-656"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">FileType -&gt; Bool
</span><a href="System.Directory.Internal.Common.html#fileTypeIsDirectory"><span class="hs-identifier hs-var">fileTypeIsDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">(FileType -&gt; Bool) -&gt; (Metadata -&gt; FileType) -&gt; Metadata -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata -&gt; FileType
</span><a href="System.Directory.Internal.Windows.html#fileTypeFromMetadata"><span class="hs-identifier hs-var">fileTypeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">(Metadata -&gt; Bool)
-&gt; Either IOError Metadata -&gt; Either IOError Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Either IOError Metadata
</span><a href="#local-6989586621679048776"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-657"></span><span>            </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IO ()) -&gt; (IOError -&gt; IOError) -&gt; IOError -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#ioeSetErrorString"><span class="hs-operator hs-var">`ioeSetErrorString`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;is a directory&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IO ()) -&gt; IOError -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-658"></span><span>                          </span><span class="annot"><span class="annottext">IOErrorType
-&gt; FilePath -&gt; Maybe Handle -&gt; Maybe FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#mkIOError"><span class="hs-identifier hs-var">mkIOError</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#InappropriateType"><span class="hs-identifier hs-var">InappropriateType</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; Maybe FilePath
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048777"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-659"></span><span>            </span><span class="annot"><span class="annottext">Either IOError Bool
</span><span class="hs-identifier">_</span></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-660"></span><span>
</span><span id="line-661"></span><span class="hs-comment">-- | Rename a file or directory.  If the destination path already exists, it</span><span>
</span><span id="line-662"></span><span class="hs-comment">-- is replaced atomically.  The destination path must not point to an existing</span><span>
</span><span id="line-663"></span><span class="hs-comment">-- directory.  A conformant implementation need not support renaming files in</span><span>
</span><span id="line-664"></span><span class="hs-comment">-- all situations (e.g. renaming across different physical devices), but the</span><span>
</span><span id="line-665"></span><span class="hs-comment">-- constraints must be documented.</span><span>
</span><span id="line-666"></span><span class="hs-comment">--</span><span>
</span><span id="line-667"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-668"></span><span class="hs-comment">--</span><span>
</span><span id="line-669"></span><span class="hs-comment">-- * @HardwareFault@</span><span>
</span><span id="line-670"></span><span class="hs-comment">-- A physical I\/O error has occurred.</span><span>
</span><span id="line-671"></span><span class="hs-comment">-- @[EIO]@</span><span>
</span><span id="line-672"></span><span class="hs-comment">--</span><span>
</span><span id="line-673"></span><span class="hs-comment">-- * @InvalidArgument@</span><span>
</span><span id="line-674"></span><span class="hs-comment">-- Either operand is not a valid file name.</span><span>
</span><span id="line-675"></span><span class="hs-comment">-- @[ENAMETOOLONG, ELOOP]@</span><span>
</span><span id="line-676"></span><span class="hs-comment">--</span><span>
</span><span id="line-677"></span><span class="hs-comment">-- * 'isDoesNotExistError'</span><span>
</span><span id="line-678"></span><span class="hs-comment">-- The original file does not exist, or there is no path to the target.</span><span>
</span><span id="line-679"></span><span class="hs-comment">-- @[ENOENT, ENOTDIR]@</span><span>
</span><span id="line-680"></span><span class="hs-comment">--</span><span>
</span><span id="line-681"></span><span class="hs-comment">-- * 'isPermissionError'</span><span>
</span><span id="line-682"></span><span class="hs-comment">-- The process has insufficient privileges to perform the operation.</span><span>
</span><span id="line-683"></span><span class="hs-comment">-- @[EROFS, EACCES, EPERM]@</span><span>
</span><span id="line-684"></span><span class="hs-comment">--</span><span>
</span><span id="line-685"></span><span class="hs-comment">-- * 'System.IO.isFullError'</span><span>
</span><span id="line-686"></span><span class="hs-comment">-- Insufficient resources are available to perform the operation.</span><span>
</span><span id="line-687"></span><span class="hs-comment">-- @[EDQUOT, ENOSPC, ENOMEM, EMLINK]@</span><span>
</span><span id="line-688"></span><span class="hs-comment">--</span><span>
</span><span id="line-689"></span><span class="hs-comment">-- * @UnsatisfiedConstraints@</span><span>
</span><span id="line-690"></span><span class="hs-comment">-- Implementation-dependent constraints are not satisfied.</span><span>
</span><span id="line-691"></span><span class="hs-comment">-- @[EBUSY]@</span><span>
</span><span id="line-692"></span><span class="hs-comment">--</span><span>
</span><span id="line-693"></span><span class="hs-comment">-- * @UnsupportedOperation@</span><span>
</span><span id="line-694"></span><span class="hs-comment">-- The implementation does not support renaming in this situation.</span><span>
</span><span id="line-695"></span><span class="hs-comment">-- @[EXDEV]@</span><span>
</span><span id="line-696"></span><span class="hs-comment">--</span><span>
</span><span id="line-697"></span><span class="hs-comment">-- * @InappropriateType@</span><span>
</span><span id="line-698"></span><span class="hs-comment">-- Either the destination path refers to an existing directory, or one of the</span><span>
</span><span id="line-699"></span><span class="hs-comment">-- parent segments in the destination path is not a directory.</span><span>
</span><span id="line-700"></span><span class="hs-comment">-- @[ENOTDIR, EISDIR, EINVAL, EEXIST, ENOTEMPTY]@</span><span>
</span><span id="line-701"></span><span class="hs-comment">--</span><span>
</span><span id="line-702"></span><span class="hs-comment">-- @since 1.2.7.0</span><span>
</span><span id="line-703"></span><span class="annot"><a href="System.Directory.html#renamePath"><span class="hs-identifier hs-type">renamePath</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                  </span><span class="hs-comment">-- ^ Old path</span><span>
</span><span id="line-704"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                  </span><span class="hs-comment">-- ^ New path</span><span>
</span><span id="line-705"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-706"></span><span id="renamePath"><span class="annot"><span class="annottext">renamePath :: FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#renamePath"><span class="hs-identifier hs-var hs-var">renamePath</span></a></span></span><span> </span><span id="local-6989586621679048773"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048773"><span class="hs-identifier hs-var">opath</span></a></span></span><span> </span><span id="local-6989586621679048772"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048772"><span class="hs-identifier hs-var">npath</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-707"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;renamePath&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-708"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#renamePathInternal"><span class="hs-identifier hs-var">renamePathInternal</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048773"><span class="hs-identifier hs-var">opath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048772"><span class="hs-identifier hs-var">npath</span></a></span><span>
</span><span id="line-709"></span><span>
</span><span id="line-710"></span><span class="hs-comment">-- | Copy a file with its permissions.  If the destination file already exists,</span><span>
</span><span id="line-711"></span><span class="hs-comment">-- it is replaced atomically.  Neither path may refer to an existing</span><span>
</span><span id="line-712"></span><span class="hs-comment">-- directory.  No exceptions are thrown if the permissions could not be</span><span>
</span><span id="line-713"></span><span class="hs-comment">-- copied.</span><span>
</span><span id="line-714"></span><span class="annot"><a href="System.Directory.html#copyFile"><span class="hs-identifier hs-type">copyFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                    </span><span class="hs-comment">-- ^ Source filename</span><span>
</span><span id="line-715"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                    </span><span class="hs-comment">-- ^ Destination filename</span><span>
</span><span id="line-716"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-717"></span><span id="copyFile"><span class="annot"><span class="annottext">copyFile :: FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#copyFile"><span class="hs-identifier hs-var hs-var">copyFile</span></a></span></span><span> </span><span id="local-6989586621679048770"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048770"><span class="hs-identifier hs-var">fromFPath</span></a></span></span><span> </span><span id="local-6989586621679048769"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048769"><span class="hs-identifier hs-var">toFPath</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-718"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;copyFile&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-719"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; (FilePath -&gt; IO ()) -&gt; IO ()
</span><a href="System.Directory.html#atomicCopyFileContents"><span class="hs-identifier hs-var">atomicCopyFileContents</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048770"><span class="hs-identifier hs-var">fromFPath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048769"><span class="hs-identifier hs-var">toFPath</span></a></span><span>
</span><span id="line-720"></span><span>      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="System.Directory.Internal.Common.html#ignoreIOExceptions"><span class="hs-identifier hs-var">ignoreIOExceptions</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; (FilePath -&gt; IO ()) -&gt; FilePath -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#copyPermissions"><span class="hs-identifier hs-var">copyPermissions</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048770"><span class="hs-identifier hs-var">fromFPath</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-721"></span><span>
</span><span id="line-722"></span><span class="hs-comment">-- | Copy the contents of a source file to a destination file, replacing the</span><span>
</span><span id="line-723"></span><span class="hs-comment">-- destination file atomically via @withReplacementFile@, resetting the</span><span>
</span><span id="line-724"></span><span class="hs-comment">-- attributes of the destination file to the defaults.</span><span>
</span><span id="line-725"></span><span class="annot"><a href="System.Directory.html#atomicCopyFileContents"><span class="hs-identifier hs-type">atomicCopyFileContents</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>            </span><span class="hs-comment">-- ^ Source filename</span><span>
</span><span id="line-726"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>            </span><span class="hs-comment">-- ^ Destination filename</span><span>
</span><span id="line-727"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ^ Post-action</span><span>
</span><span id="line-728"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-729"></span><span id="atomicCopyFileContents"><span class="annot"><span class="annottext">atomicCopyFileContents :: FilePath -&gt; FilePath -&gt; (FilePath -&gt; IO ()) -&gt; IO ()
</span><a href="System.Directory.html#atomicCopyFileContents"><span class="hs-identifier hs-var hs-var">atomicCopyFileContents</span></a></span></span><span> </span><span id="local-6989586621679048766"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048766"><span class="hs-identifier hs-var">fromFPath</span></a></span></span><span> </span><span id="local-6989586621679048765"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048765"><span class="hs-identifier hs-var">toFPath</span></a></span></span><span> </span><span id="local-6989586621679048764"><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="#local-6989586621679048764"><span class="hs-identifier hs-var">postAction</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-730"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;atomicCopyFileContents&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-731"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; (FilePath -&gt; IO ()) -&gt; (Handle -&gt; IO ()) -&gt; IO ()
forall a.
FilePath -&gt; (FilePath -&gt; IO ()) -&gt; (Handle -&gt; IO a) -&gt; IO a
</span><a href="System.Directory.html#withReplacementFile"><span class="hs-identifier hs-var">withReplacementFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048765"><span class="hs-identifier hs-var">toFPath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="#local-6989586621679048764"><span class="hs-identifier hs-var">postAction</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle -&gt; IO ()) -&gt; IO ()) -&gt; (Handle -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679048762"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048762"><span class="hs-identifier hs-var">hTo</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-732"></span><span>      </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; IO ()
</span><a href="System.Directory.Internal.Common.html#copyFileToHandle"><span class="hs-identifier hs-var">copyFileToHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048766"><span class="hs-identifier hs-var">fromFPath</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048762"><span class="hs-identifier hs-var">hTo</span></a></span><span>
</span><span id="line-733"></span><span>
</span><span id="line-734"></span><span class="hs-comment">-- | A helper function useful for replacing files in an atomic manner.  The</span><span>
</span><span id="line-735"></span><span class="hs-comment">-- function creates a temporary file in the directory of the destination file,</span><span>
</span><span id="line-736"></span><span class="hs-comment">-- opens it, performs the main action with its handle, closes it, performs the</span><span>
</span><span id="line-737"></span><span class="hs-comment">-- post-action with its path, and finally replaces the destination file with</span><span>
</span><span id="line-738"></span><span class="hs-comment">-- the temporary file.  If an error occurs during any step of this process,</span><span>
</span><span id="line-739"></span><span class="hs-comment">-- the temporary file is removed and the destination file remains untouched.</span><span>
</span><span id="line-740"></span><span id="local-6989586621679049051"><span class="annot"><a href="System.Directory.html#withReplacementFile"><span class="hs-identifier hs-type">withReplacementFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>            </span><span class="hs-comment">-- ^ Destination file</span><span>
</span><span id="line-741"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ^ Post-action</span><span>
</span><span id="line-742"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679049051"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>    </span><span class="hs-comment">-- ^ Main action</span><span>
</span><span id="line-743"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679049051"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-744"></span><span id="withReplacementFile"><span class="annot"><span class="annottext">withReplacementFile :: forall a.
FilePath -&gt; (FilePath -&gt; IO ()) -&gt; (Handle -&gt; IO a) -&gt; IO a
</span><a href="System.Directory.html#withReplacementFile"><span class="hs-identifier hs-var hs-var">withReplacementFile</span></a></span></span><span> </span><span id="local-6989586621679048754"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048754"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679048753"><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="#local-6989586621679048753"><span class="hs-identifier hs-var">postAction</span></a></span></span><span> </span><span id="local-6989586621679048752"><span class="annot"><span class="annottext">Handle -&gt; IO a
</span><a href="#local-6989586621679048752"><span class="hs-identifier hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-745"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;withReplacementFile&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO a -&gt; IO a
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-746"></span><span>    </span><span class="annot"><span class="annottext">((forall a. IO a -&gt; IO a) -&gt; IO a) -&gt; IO a
forall b. ((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.IO.html#mask"><span class="hs-identifier hs-var">mask</span></a></span><span> </span><span class="annot"><span class="annottext">(((forall a. IO a -&gt; IO a) -&gt; IO a) -&gt; IO a)
-&gt; ((forall a. IO a -&gt; IO a) -&gt; IO a) -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679048750"><span class="annot"><span class="annottext">forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679048750"><span class="hs-identifier hs-var">restore</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-747"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621679048749"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048749"><span class="hs-identifier hs-var">tmpFPath</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048748"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048748"><span class="hs-identifier hs-var">hTmp</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; IO (FilePath, Handle)
</span><a href="../../base/src/System.IO.html#openBinaryTempFile"><span class="hs-identifier hs-var">openBinaryTempFile</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#takeDirectory"><span class="hs-identifier hs-var">takeDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048754"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-748"></span><span>                                             </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;.copyFile.tmp&quot;</span></span><span>
</span><span id="line-749"></span><span>      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO a -&gt; IO () -&gt; IO a
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="../../base/src/Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`onException`</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="System.Directory.Internal.Common.html#ignoreIOExceptions"><span class="hs-identifier hs-var">ignoreIOExceptions</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeFile"><span class="hs-identifier hs-var">removeFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048749"><span class="hs-identifier hs-var">tmpFPath</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO a -&gt; IO a) -&gt; IO a -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-750"></span><span>        </span><span id="local-6989586621679048745"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679048745"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO a -&gt; IO () -&gt; IO a
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="../../base/src/Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`onException`</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="System.Directory.Internal.Common.html#ignoreIOExceptions"><span class="hs-identifier hs-var">ignoreIOExceptions</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048748"><span class="hs-identifier hs-var">hTmp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO a -&gt; IO a) -&gt; IO a -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-751"></span><span>          </span><span class="annot"><span class="annottext">IO a -&gt; IO a
forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679048750"><span class="hs-identifier hs-var">restore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; IO a
</span><a href="#local-6989586621679048752"><span class="hs-identifier hs-var">action</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048748"><span class="hs-identifier hs-var">hTmp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-752"></span><span>        </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679048748"><span class="hs-identifier hs-var">hTmp</span></a></span><span>
</span><span id="line-753"></span><span>        </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679048750"><span class="hs-identifier hs-var">restore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="#local-6989586621679048753"><span class="hs-identifier hs-var">postAction</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048749"><span class="hs-identifier hs-var">tmpFPath</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-754"></span><span>        </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#renameFile"><span class="hs-identifier hs-var">renameFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048749"><span class="hs-identifier hs-var">tmpFPath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048754"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-755"></span><span>        </span><span class="annot"><span class="annottext">a -&gt; IO a
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679048745"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-756"></span><span>
</span><span id="line-757"></span><span class="hs-comment">-- | Copy a file with its associated metadata.  If the destination file</span><span>
</span><span id="line-758"></span><span class="hs-comment">-- already exists, it is overwritten.  There is no guarantee of atomicity in</span><span>
</span><span id="line-759"></span><span class="hs-comment">-- the replacement of the destination file.  Neither path may refer to an</span><span>
</span><span id="line-760"></span><span class="hs-comment">-- existing directory.  If the source and/or destination are symbolic links,</span><span>
</span><span id="line-761"></span><span class="hs-comment">-- the copy is performed on the targets of the links.</span><span>
</span><span id="line-762"></span><span class="hs-comment">--</span><span>
</span><span id="line-763"></span><span class="hs-comment">-- On Windows, it behaves like the Win32 function</span><span>
</span><span id="line-764"></span><span class="hs-comment">-- &lt;https://msdn.microsoft.com/en-us/library/windows/desktop/aa363851.aspx CopyFile&gt;,</span><span>
</span><span id="line-765"></span><span class="hs-comment">-- which copies various kinds of metadata including file attributes and</span><span>
</span><span id="line-766"></span><span class="hs-comment">-- security resource properties.</span><span>
</span><span id="line-767"></span><span class="hs-comment">--</span><span>
</span><span id="line-768"></span><span class="hs-comment">-- On Unix-like systems, permissions, access time, and modification time are</span><span>
</span><span id="line-769"></span><span class="hs-comment">-- preserved.  If possible, the owner and group are also preserved.  Note that</span><span>
</span><span id="line-770"></span><span class="hs-comment">-- the very act of copying can change the access time of the source file,</span><span>
</span><span id="line-771"></span><span class="hs-comment">-- hence the access times of the two files may differ after the operation</span><span>
</span><span id="line-772"></span><span class="hs-comment">-- completes.</span><span>
</span><span id="line-773"></span><span class="hs-comment">--</span><span>
</span><span id="line-774"></span><span class="hs-comment">-- @since 1.2.6.0</span><span>
</span><span id="line-775"></span><span class="annot"><a href="System.Directory.html#copyFileWithMetadata"><span class="hs-identifier hs-type">copyFileWithMetadata</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>        </span><span class="hs-comment">-- ^ Source file</span><span>
</span><span id="line-776"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>        </span><span class="hs-comment">-- ^ Destination file</span><span>
</span><span id="line-777"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-778"></span><span id="copyFileWithMetadata"><span class="annot"><span class="annottext">copyFileWithMetadata :: FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#copyFileWithMetadata"><span class="hs-identifier hs-var hs-var">copyFileWithMetadata</span></a></span></span><span> </span><span id="local-6989586621679048743"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048743"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span id="local-6989586621679048742"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048742"><span class="hs-identifier hs-var">dst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-779"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;copyFileWithMetadata&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span>
</span><span id="line-780"></span><span>    </span><span class="annot"><span class="annottext">(Metadata -&gt; FilePath -&gt; IO ())
-&gt; (Metadata -&gt; FilePath -&gt; IO ()) -&gt; FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#copyFileWithMetadataInternal"><span class="hs-identifier hs-var">copyFileWithMetadataInternal</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#copyPermissionsFromMetadata"><span class="hs-identifier hs-var">copyPermissionsFromMetadata</span></a></span><span>
</span><span id="line-781"></span><span>                                 </span><span class="annot"><span class="annottext">Metadata -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#copyTimesFromMetadata"><span class="hs-identifier hs-var">copyTimesFromMetadata</span></a></span><span>
</span><span id="line-782"></span><span>                                 </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048743"><span class="hs-identifier hs-var">src</span></a></span><span>
</span><span id="line-783"></span><span>                                 </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048742"><span class="hs-identifier hs-var">dst</span></a></span><span>
</span><span id="line-784"></span><span>
</span><span id="line-785"></span><span class="annot"><a href="System.Directory.html#copyTimesFromMetadata"><span class="hs-identifier hs-type">copyTimesFromMetadata</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Directory.Internal.Windows.html#Metadata"><span class="hs-identifier hs-type">Metadata</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-786"></span><span id="copyTimesFromMetadata"><span class="annot"><span class="annottext">copyTimesFromMetadata :: Metadata -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#copyTimesFromMetadata"><span class="hs-identifier hs-var hs-var">copyTimesFromMetadata</span></a></span></span><span> </span><span id="local-6989586621679048739"><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048739"><span class="hs-identifier hs-var">st</span></a></span></span><span> </span><span id="local-6989586621679048738"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048738"><span class="hs-identifier hs-var">dst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-787"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679048737"><span class="annot"><span class="annottext">atime :: UTCTime
</span><a href="#local-6989586621679048737"><span class="hs-identifier hs-var hs-var">atime</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Metadata -&gt; UTCTime
</span><a href="System.Directory.Internal.Windows.html#accessTimeFromMetadata"><span class="hs-identifier hs-var">accessTimeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048739"><span class="hs-identifier hs-var">st</span></a></span><span>
</span><span id="line-788"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679048735"><span class="annot"><span class="annottext">mtime :: UTCTime
</span><a href="#local-6989586621679048735"><span class="hs-identifier hs-var hs-var">mtime</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Metadata -&gt; UTCTime
</span><a href="System.Directory.Internal.Windows.html#modificationTimeFromMetadata"><span class="hs-identifier hs-var">modificationTimeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata
</span><a href="#local-6989586621679048739"><span class="hs-identifier hs-var">st</span></a></span><span>
</span><span id="line-789"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; (Maybe UTCTime, Maybe UTCTime) -&gt; IO ()
</span><a href="System.Directory.html#setFileTimes"><span class="hs-identifier hs-var">setFileTimes</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048738"><span class="hs-identifier hs-var">dst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UTCTime -&gt; Maybe UTCTime
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">UTCTime
</span><a href="#local-6989586621679048737"><span class="hs-identifier hs-var">atime</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UTCTime -&gt; Maybe UTCTime
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">UTCTime
</span><a href="#local-6989586621679048735"><span class="hs-identifier hs-var">mtime</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-790"></span><span>
</span><span id="line-791"></span><span class="hs-comment">-- | Make a path absolute, normalize the path, and remove as many indirections</span><span>
</span><span id="line-792"></span><span class="hs-comment">-- from it as possible.  Any trailing path separators are discarded via</span><span>
</span><span id="line-793"></span><span class="hs-comment">-- 'dropTrailingPathSeparator'.  Additionally, on Windows the letter case of</span><span>
</span><span id="line-794"></span><span class="hs-comment">-- the path is canonicalized.</span><span>
</span><span id="line-795"></span><span class="hs-comment">--</span><span>
</span><span id="line-796"></span><span class="hs-comment">-- __Note__: This function is a very big hammer.  If you only need an absolute</span><span>
</span><span id="line-797"></span><span class="hs-comment">-- path, 'makeAbsolute' is sufficient for removing dependence on the current</span><span>
</span><span id="line-798"></span><span class="hs-comment">-- working directory.</span><span>
</span><span id="line-799"></span><span class="hs-comment">--</span><span>
</span><span id="line-800"></span><span class="hs-comment">-- Indirections include the two special directories @.@ and @..@, as well as</span><span>
</span><span id="line-801"></span><span class="hs-comment">-- any symbolic links (and junction points on Windows).  The input path need</span><span>
</span><span id="line-802"></span><span class="hs-comment">-- not point to an existing file or directory.  Canonicalization is performed</span><span>
</span><span id="line-803"></span><span class="hs-comment">-- on the longest prefix of the path that points to an existing file or</span><span>
</span><span id="line-804"></span><span class="hs-comment">-- directory.  The remaining portion of the path that does not point to an</span><span>
</span><span id="line-805"></span><span class="hs-comment">-- existing file or directory will still be normalized, but case</span><span>
</span><span id="line-806"></span><span class="hs-comment">-- canonicalization and indirection removal are skipped as they are impossible</span><span>
</span><span id="line-807"></span><span class="hs-comment">-- to do on a nonexistent path.</span><span>
</span><span id="line-808"></span><span class="hs-comment">--</span><span>
</span><span id="line-809"></span><span class="hs-comment">-- Most programs should not worry about the canonicity of a path.  In</span><span>
</span><span id="line-810"></span><span class="hs-comment">-- particular, despite the name, the function does not truly guarantee</span><span>
</span><span id="line-811"></span><span class="hs-comment">-- canonicity of the returned path due to the presence of hard links, mount</span><span>
</span><span id="line-812"></span><span class="hs-comment">-- points, etc.</span><span>
</span><span id="line-813"></span><span class="hs-comment">--</span><span>
</span><span id="line-814"></span><span class="hs-comment">-- If the path points to an existing file or directory, then the output path</span><span>
</span><span id="line-815"></span><span class="hs-comment">-- shall also point to the same file or directory, subject to the condition</span><span>
</span><span id="line-816"></span><span class="hs-comment">-- that the relevant parts of the file system do not change while the function</span><span>
</span><span id="line-817"></span><span class="hs-comment">-- is still running.  In other words, the function is definitively not atomic.</span><span>
</span><span id="line-818"></span><span class="hs-comment">-- The results can be utterly wrong if the portions of the path change while</span><span>
</span><span id="line-819"></span><span class="hs-comment">-- this function is running.</span><span>
</span><span id="line-820"></span><span class="hs-comment">--</span><span>
</span><span id="line-821"></span><span class="hs-comment">-- Since some indirections (symbolic links on all systems, @..@ on non-Windows</span><span>
</span><span id="line-822"></span><span class="hs-comment">-- systems, and junction points on Windows) are dependent on the state of the</span><span>
</span><span id="line-823"></span><span class="hs-comment">-- existing filesystem, the function can only make a conservative attempt by</span><span>
</span><span id="line-824"></span><span class="hs-comment">-- removing such indirections from the longest prefix of the path that still</span><span>
</span><span id="line-825"></span><span class="hs-comment">-- points to an existing file or directory.</span><span>
</span><span id="line-826"></span><span class="hs-comment">--</span><span>
</span><span id="line-827"></span><span class="hs-comment">-- Note that on Windows parent directories @..@ are always fully expanded</span><span>
</span><span id="line-828"></span><span class="hs-comment">-- before the symbolic links, as consistent with the rest of the Windows API</span><span>
</span><span id="line-829"></span><span class="hs-comment">-- (such as @GetFullPathName@).  In contrast, on POSIX systems parent</span><span>
</span><span id="line-830"></span><span class="hs-comment">-- directories @..@ are expanded alongside symbolic links from left to right.</span><span>
</span><span id="line-831"></span><span class="hs-comment">-- To put this more concretely: if @L@ is a symbolic link for @R/P@, then on</span><span>
</span><span id="line-832"></span><span class="hs-comment">-- Windows @L\\..@ refers to @.@, whereas on other operating systems @L/..@</span><span>
</span><span id="line-833"></span><span class="hs-comment">-- refers to @R@.</span><span>
</span><span id="line-834"></span><span class="hs-comment">--</span><span>
</span><span id="line-835"></span><span class="hs-comment">-- Similar to 'System.FilePath.normalise', passing an empty path is equivalent</span><span>
</span><span id="line-836"></span><span class="hs-comment">-- to passing the current directory.</span><span>
</span><span id="line-837"></span><span class="hs-comment">--</span><span>
</span><span id="line-838"></span><span class="hs-comment">-- @canonicalizePath@ can resolve at least 64 indirections in a single path,</span><span>
</span><span id="line-839"></span><span class="hs-comment">-- more than what is supported by most operating systems.  Therefore, it may</span><span>
</span><span id="line-840"></span><span class="hs-comment">-- return the fully resolved path even though the operating system itself</span><span>
</span><span id="line-841"></span><span class="hs-comment">-- would have long given up.</span><span>
</span><span id="line-842"></span><span class="hs-comment">--</span><span>
</span><span id="line-843"></span><span class="hs-comment">-- On Windows XP or earlier systems, junction expansion is not performed due</span><span>
</span><span id="line-844"></span><span class="hs-comment">-- to their lack of @GetFinalPathNameByHandle@.</span><span>
</span><span id="line-845"></span><span class="hs-comment">--</span><span>
</span><span id="line-846"></span><span class="hs-comment">-- /Changes since 1.2.3.0:/ The function has been altered to be more robust</span><span>
</span><span id="line-847"></span><span class="hs-comment">-- and has the same exception behavior as 'makeAbsolute'.</span><span>
</span><span id="line-848"></span><span class="hs-comment">--</span><span>
</span><span id="line-849"></span><span class="hs-comment">-- /Changes since 1.3.0.0:/ The function no longer preserves the trailing path</span><span>
</span><span id="line-850"></span><span class="hs-comment">-- separator.  File symbolic links that appear in the middle of a path are</span><span>
</span><span id="line-851"></span><span class="hs-comment">-- properly dereferenced.  Case canonicalization and symbolic link expansion</span><span>
</span><span id="line-852"></span><span class="hs-comment">-- are now performed on Windows.</span><span>
</span><span id="line-853"></span><span class="hs-comment">--</span><span>
</span><span id="line-854"></span><span class="annot"><a href="System.Directory.html#canonicalizePath"><span class="hs-identifier hs-type">canonicalizePath</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-855"></span><span id="canonicalizePath"><span class="annot"><span class="annottext">canonicalizePath :: FilePath -&gt; IO FilePath
</span><a href="System.Directory.html#canonicalizePath"><span class="hs-identifier hs-var hs-var">canonicalizePath</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679048732"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048732"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-856"></span><span>  </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;canonicalizePath&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; (IOError -&gt; IOError) -&gt; IOError -&gt; IOError
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-857"></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#ioeSetFileName"><span class="hs-operator hs-var">`ioeSetFileName`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048732"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO FilePath -&gt; IO FilePath
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-858"></span><span>    </span><span class="hs-comment">-- simplify does more stuff, like upper-casing the drive letter</span><span>
</span><span id="line-859"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#dropTrailingPathSeparator"><span class="hs-identifier hs-var">dropTrailingPathSeparator</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="System.Directory.Internal.Windows.html#simplify"><span class="hs-identifier hs-var">simplify</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath) -&gt; IO FilePath -&gt; IO FilePath
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span>
</span><span id="line-860"></span><span>      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((FilePath -&gt; IO FilePath) -&gt; FilePath -&gt; IO FilePath)
-&gt; FilePath -&gt; IO FilePath
</span><a href="System.Directory.Internal.Windows.html#canonicalizePathWith"><span class="hs-identifier hs-var">canonicalizePathWith</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO FilePath) -&gt; FilePath -&gt; IO FilePath
</span><a href="#local-6989586621679048729"><span class="hs-identifier hs-var">attemptRealpath</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO FilePath) -&gt; IO FilePath -&gt; IO FilePath
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="System.Directory.Internal.Windows.html#prependCurrentDirectory"><span class="hs-identifier hs-var">prependCurrentDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048732"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-861"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-862"></span><span>
</span><span id="line-863"></span><span>    </span><span class="hs-comment">-- allow up to 64 cycles before giving up</span><span>
</span><span id="line-864"></span><span>    </span><span id="local-6989586621679048729"><span class="annot"><span class="annottext">attemptRealpath :: (FilePath -&gt; IO FilePath) -&gt; FilePath -&gt; IO FilePath
</span><a href="#local-6989586621679048729"><span class="hs-identifier hs-var hs-var">attemptRealpath</span></a></span></span><span> </span><span id="local-6989586621679048721"><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="#local-6989586621679048721"><span class="hs-identifier hs-var">realpath</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-865"></span><span>      </span><span class="annot"><span class="annottext">Int
-&gt; Maybe FilePath
-&gt; (FilePath -&gt; IO FilePath)
-&gt; FilePath
-&gt; IO FilePath
forall {a}.
(Ord a, Num a) =&gt;
a
-&gt; Maybe FilePath
-&gt; (FilePath -&gt; IO FilePath)
-&gt; FilePath
-&gt; IO FilePath
</span><a href="#local-6989586621679048720"><span class="hs-identifier hs-var">attemptRealpathWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">64</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe FilePath
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="#local-6989586621679048721"><span class="hs-identifier hs-var">realpath</span></a></span><span>
</span><span id="line-866"></span><span>      </span><span class="annot"><span class="annottext">(FilePath -&gt; IO FilePath)
-&gt; (FilePath -&gt; IO FilePath) -&gt; FilePath -&gt; IO FilePath
forall (m :: * -&gt; *) b c a.
Monad m =&gt;
(b -&gt; m c) -&gt; (a -&gt; m b) -&gt; a -&gt; m c
</span><a href="../../base/src/Control.Monad.html#%3C%3D%3C"><span class="hs-operator hs-var">&lt;=&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="System.Directory.Internal.Windows.html#canonicalizePathSimplify"><span class="hs-identifier hs-var">canonicalizePathSimplify</span></a></span><span>
</span><span id="line-867"></span><span>
</span><span id="line-868"></span><span>    </span><span class="hs-comment">-- n is a counter to make sure we don't run into an infinite loop; we</span><span>
</span><span id="line-869"></span><span>    </span><span class="hs-comment">-- don't try to do any cycle detection here because an adversary could DoS</span><span>
</span><span id="line-870"></span><span>    </span><span class="hs-comment">-- any arbitrarily clever algorithm</span><span>
</span><span id="line-871"></span><span>    </span><span id="local-6989586621679048720"><span class="annot"><span class="annottext">attemptRealpathWith :: a
-&gt; Maybe FilePath
-&gt; (FilePath -&gt; IO FilePath)
-&gt; FilePath
-&gt; IO FilePath
</span><a href="#local-6989586621679048720"><span class="hs-identifier hs-var hs-var">attemptRealpathWith</span></a></span></span><span> </span><span id="local-6989586621679048712"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679048712"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679048711"><span class="annot"><span class="annottext">Maybe FilePath
</span><a href="#local-6989586621679048711"><span class="hs-identifier hs-var">mFallback</span></a></span></span><span> </span><span id="local-6989586621679048710"><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="#local-6989586621679048710"><span class="hs-identifier hs-var">realpath</span></a></span></span><span> </span><span id="local-6989586621679048709"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048709"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-872"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe FilePath
</span><a href="#local-6989586621679048711"><span class="hs-identifier hs-var">mFallback</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-873"></span><span>        </span><span class="hs-comment">-- too many indirections ... giving up.</span><span>
</span><span id="line-874"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048708"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048708"><span class="hs-identifier hs-var">fallback</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679048712"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048708"><span class="hs-identifier hs-var">fallback</span></a></span><span>
</span><span id="line-875"></span><span>        </span><span class="hs-comment">-- either mFallback == Nothing (first attempt)</span><span>
</span><span id="line-876"></span><span>        </span><span class="hs-comment">--     or n &gt; 0 (still have some attempts left)</span><span>
</span><span id="line-877"></span><span>        </span><span class="annot"><span class="annottext">Maybe FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[(FilePath, FilePath)] -&gt; IO FilePath
</span><a href="#local-6989586621679048706"><span class="hs-identifier hs-var">realpathPrefix</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(FilePath, FilePath)] -&gt; [(FilePath, FilePath)]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[FilePath] -&gt; [FilePath] -&gt; [(FilePath, FilePath)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048705"><span class="hs-identifier hs-var">prefixes</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048704"><span class="hs-identifier hs-var">suffixes</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-878"></span><span>
</span><span id="line-879"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-880"></span><span>
</span><span id="line-881"></span><span>        </span><span id="local-6989586621679048703"><span class="annot"><span class="annottext">segments :: [FilePath]
</span><a href="#local-6989586621679048703"><span class="hs-identifier hs-var hs-var">segments</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; [FilePath]
</span><a href="../../filepath/src/System.FilePath.Windows.html#splitDirectories"><span class="hs-identifier hs-var">splitDirectories</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048709"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-882"></span><span>        </span><span id="local-6989586621679048705"><span class="annot"><span class="annottext">prefixes :: [FilePath]
</span><a href="#local-6989586621679048705"><span class="hs-identifier hs-var hs-var">prefixes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath -&gt; FilePath) -&gt; [FilePath] -&gt; [FilePath]
forall a. (a -&gt; a -&gt; a) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#scanl1"><span class="hs-identifier hs-var">scanl1</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">(&lt;/&gt;)</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048703"><span class="hs-identifier hs-var">segments</span></a></span><span>
</span><span id="line-883"></span><span>        </span><span id="local-6989586621679048704"><span class="annot"><span class="annottext">suffixes :: [FilePath]
</span><a href="#local-6989586621679048704"><span class="hs-identifier hs-var hs-var">suffixes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[FilePath] -&gt; [FilePath]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#tail"><span class="hs-identifier hs-var">tail</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath -&gt; FilePath)
-&gt; FilePath -&gt; [FilePath] -&gt; [FilePath]
forall a b. (a -&gt; b -&gt; b) -&gt; b -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.List.html#scanr"><span class="hs-identifier hs-var">scanr</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">(&lt;/&gt;)</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048703"><span class="hs-identifier hs-var">segments</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-884"></span><span>
</span><span id="line-885"></span><span>        </span><span class="hs-comment">-- try to call realpath on the largest possible prefix</span><span>
</span><span id="line-886"></span><span>        </span><span id="local-6989586621679048706"><span class="annot"><span class="annottext">realpathPrefix :: [(FilePath, FilePath)] -&gt; IO FilePath
</span><a href="#local-6989586621679048706"><span class="hs-identifier hs-var hs-var">realpathPrefix</span></a></span></span><span> </span><span id="local-6989586621679048697"><span class="annot"><span class="annottext">[(FilePath, FilePath)]
</span><a href="#local-6989586621679048697"><span class="hs-identifier hs-var">candidates</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-887"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[(FilePath, FilePath)]
</span><a href="#local-6989586621679048697"><span class="hs-identifier hs-var">candidates</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-888"></span><span>            </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048709"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-889"></span><span>            </span><span class="hs-special">(</span><span id="local-6989586621679048696"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048696"><span class="hs-identifier hs-var">prefix</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048695"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048695"><span class="hs-identifier hs-var">suffix</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621679048694"><span class="annot"><span class="annottext">[(FilePath, FilePath)]
</span><a href="#local-6989586621679048694"><span class="hs-identifier hs-var">rest</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-890"></span><span>              </span><span id="local-6989586621679048693"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048693"><span class="hs-identifier hs-var">exist</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="System.Directory.html#doesPathExist"><span class="hs-identifier hs-var">doesPathExist</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048696"><span class="hs-identifier hs-var">prefix</span></a></span><span>
</span><span id="line-891"></span><span>              </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048693"><span class="hs-identifier hs-var">exist</span></a></span><span>
</span><span id="line-892"></span><span>                </span><span class="hs-comment">-- never call realpath on an inaccessible path</span><span>
</span><span id="line-893"></span><span>                </span><span class="hs-comment">-- (to avoid bugs in system realpath implementations)</span><span>
</span><span id="line-894"></span><span>                </span><span class="hs-comment">-- try a smaller prefix instead</span><span>
</span><span id="line-895"></span><span>                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[(FilePath, FilePath)] -&gt; IO FilePath
</span><a href="#local-6989586621679048706"><span class="hs-identifier hs-var">realpathPrefix</span></a></span><span> </span><span class="annot"><span class="annottext">[(FilePath, FilePath)]
</span><a href="#local-6989586621679048694"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-896"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-897"></span><span>                  </span><span id="local-6989586621679048692"><span class="annot"><span class="annottext">Either IOError FilePath
</span><a href="#local-6989586621679048692"><span class="hs-identifier hs-var">mp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO FilePath -&gt; IO (Either IOError FilePath)
forall a. IO a -&gt; IO (Either IOError a)
</span><a href="../../base/src/System.IO.Error.html#tryIOError"><span class="hs-identifier hs-var">tryIOError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="#local-6989586621679048710"><span class="hs-identifier hs-var">realpath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048696"><span class="hs-identifier hs-var">prefix</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-898"></span><span>                  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either IOError FilePath
</span><a href="#local-6989586621679048692"><span class="hs-identifier hs-var">mp</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-899"></span><span>                    </span><span class="hs-comment">-- realpath failed: try a smaller prefix instead</span><span>
</span><span id="line-900"></span><span>                    </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[(FilePath, FilePath)] -&gt; IO FilePath
</span><a href="#local-6989586621679048706"><span class="hs-identifier hs-var">realpathPrefix</span></a></span><span> </span><span class="annot"><span class="annottext">[(FilePath, FilePath)]
</span><a href="#local-6989586621679048694"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-901"></span><span>                    </span><span class="hs-comment">-- realpath succeeded: fine-tune the result</span><span>
</span><span id="line-902"></span><span>                    </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621679048691"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048691"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath -&gt; IO FilePath
</span><a href="#local-6989586621679048690"><span class="hs-identifier hs-var">realpathFurther</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048691"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048695"><span class="hs-identifier hs-var">suffix</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048691"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048695"><span class="hs-identifier hs-var">suffix</span></a></span><span>
</span><span id="line-903"></span><span>
</span><span id="line-904"></span><span>        </span><span class="hs-comment">-- by now we have a reasonable fallback value that we can use if we</span><span>
</span><span id="line-905"></span><span>        </span><span class="hs-comment">-- run into too many indirections; the fallback value is the same</span><span>
</span><span id="line-906"></span><span>        </span><span class="hs-comment">-- result that we have been returning in versions prior to 1.3.1.0</span><span>
</span><span id="line-907"></span><span>        </span><span class="hs-comment">-- (this is essentially the fix to #64)</span><span>
</span><span id="line-908"></span><span>        </span><span id="local-6989586621679048690"><span class="annot"><span class="annottext">realpathFurther :: FilePath -&gt; FilePath -&gt; FilePath -&gt; IO FilePath
</span><a href="#local-6989586621679048690"><span class="hs-identifier hs-var hs-var">realpathFurther</span></a></span></span><span> </span><span id="local-6989586621679048683"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048683"><span class="hs-identifier hs-var">fallback</span></a></span></span><span> </span><span id="local-6989586621679048682"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048682"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679048681"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048681"><span class="hs-identifier hs-var">suffix</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-909"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; [FilePath]
</span><a href="../../filepath/src/System.FilePath.Windows.html#splitDirectories"><span class="hs-identifier hs-var">splitDirectories</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048681"><span class="hs-identifier hs-var">suffix</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-910"></span><span>            </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048683"><span class="hs-identifier hs-var">fallback</span></a></span><span>
</span><span id="line-911"></span><span>            </span><span id="local-6989586621679048680"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048680"><span class="hs-identifier hs-var">next</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621679048679"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048679"><span class="hs-identifier hs-var">restSuffix</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-912"></span><span>              </span><span class="hs-comment">-- see if the 'next' segment is a symlink</span><span>
</span><span id="line-913"></span><span>              </span><span id="local-6989586621679048678"><span class="annot"><span class="annottext">Either IOError FilePath
</span><a href="#local-6989586621679048678"><span class="hs-identifier hs-var">mTarget</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO FilePath -&gt; IO (Either IOError FilePath)
forall a. IO a -&gt; IO (Either IOError a)
</span><a href="../../base/src/System.IO.Error.html#tryIOError"><span class="hs-identifier hs-var">tryIOError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="System.Directory.html#getSymbolicLinkTarget"><span class="hs-identifier hs-var">getSymbolicLinkTarget</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048682"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048680"><span class="hs-identifier hs-var">next</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-914"></span><span>              </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either IOError FilePath
</span><a href="#local-6989586621679048678"><span class="hs-identifier hs-var">mTarget</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-915"></span><span>                </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048683"><span class="hs-identifier hs-var">fallback</span></a></span><span>
</span><span id="line-916"></span><span>                </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621679048677"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048677"><span class="hs-identifier hs-var">target</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-917"></span><span>                  </span><span class="hs-comment">-- if so, dereference it and restart the whole cycle</span><span>
</span><span id="line-918"></span><span>                  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679048676"><span class="annot"><span class="annottext">mFallback' :: Maybe FilePath
</span><a href="#local-6989586621679048676"><span class="hs-identifier hs-var hs-var">mFallback'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Maybe FilePath
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; Maybe FilePath -&gt; FilePath
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048683"><span class="hs-identifier hs-var">fallback</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe FilePath
</span><a href="#local-6989586621679048711"><span class="hs-identifier hs-var">mFallback</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-919"></span><span>                  </span><span id="local-6989586621679048674"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048674"><span class="hs-identifier hs-var">path'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="System.Directory.Internal.Windows.html#canonicalizePathSimplify"><span class="hs-identifier hs-var">canonicalizePathSimplify</span></a></span><span>
</span><span id="line-920"></span><span>                             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048682"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048677"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath] -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#joinPath"><span class="hs-identifier hs-var">joinPath</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048679"><span class="hs-identifier hs-var">restSuffix</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-921"></span><span>                  </span><span class="annot"><span class="annottext">a
-&gt; Maybe FilePath
-&gt; (FilePath -&gt; IO FilePath)
-&gt; FilePath
-&gt; IO FilePath
</span><a href="#local-6989586621679048720"><span class="hs-identifier hs-var">attemptRealpathWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679048712"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; a
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe FilePath
</span><a href="#local-6989586621679048676"><span class="hs-identifier hs-var">mFallback'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="#local-6989586621679048710"><span class="hs-identifier hs-var">realpath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048674"><span class="hs-identifier hs-var">path'</span></a></span><span>
</span><span id="line-922"></span><span>
</span><span id="line-923"></span><span class="hs-comment">-- | Convert a path into an absolute path.  If the given path is relative, the</span><span>
</span><span id="line-924"></span><span class="hs-comment">-- current directory is prepended and then the combined result is normalized.</span><span>
</span><span id="line-925"></span><span class="hs-comment">-- If the path is already absolute, the path is simply normalized.  The</span><span>
</span><span id="line-926"></span><span class="hs-comment">-- function preserves the presence or absence of the trailing path separator</span><span>
</span><span id="line-927"></span><span class="hs-comment">-- unless the path refers to the root directory @/@.</span><span>
</span><span id="line-928"></span><span class="hs-comment">--</span><span>
</span><span id="line-929"></span><span class="hs-comment">-- If the path is already absolute, the operation never fails.  Otherwise, the</span><span>
</span><span id="line-930"></span><span class="hs-comment">-- operation may fail with the same exceptions as 'getCurrentDirectory'.</span><span>
</span><span id="line-931"></span><span class="hs-comment">--</span><span>
</span><span id="line-932"></span><span class="hs-comment">-- @since 1.2.2.0</span><span>
</span><span id="line-933"></span><span class="hs-comment">--</span><span>
</span><span id="line-934"></span><span class="annot"><a href="System.Directory.html#makeAbsolute"><span class="hs-identifier hs-type">makeAbsolute</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-935"></span><span id="makeAbsolute"><span class="annot"><span class="annottext">makeAbsolute :: FilePath -&gt; IO FilePath
</span><a href="System.Directory.html#makeAbsolute"><span class="hs-identifier hs-var hs-var">makeAbsolute</span></a></span></span><span> </span><span id="local-6989586621679048673"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048673"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-936"></span><span>  </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;makeAbsolute&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; (IOError -&gt; IOError) -&gt; IOError -&gt; IOError
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-937"></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#ioeSetFileName"><span class="hs-operator hs-var">`ioeSetFileName`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048673"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO FilePath -&gt; IO FilePath
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-938"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="System.Directory.html#matchTrailingSeparator"><span class="hs-identifier hs-var">matchTrailingSeparator</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048673"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="System.Directory.Internal.Windows.html#simplify"><span class="hs-identifier hs-var">simplify</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath) -&gt; IO FilePath -&gt; IO FilePath
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="System.Directory.Internal.Windows.html#prependCurrentDirectory"><span class="hs-identifier hs-var">prependCurrentDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048673"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-939"></span><span>
</span><span id="line-940"></span><span class="hs-comment">-- | Add or remove the trailing path separator in the second path so as to</span><span>
</span><span id="line-941"></span><span class="hs-comment">-- match its presence in the first path.</span><span>
</span><span id="line-942"></span><span class="hs-comment">--</span><span>
</span><span id="line-943"></span><span class="hs-comment">-- (internal API)</span><span>
</span><span id="line-944"></span><span class="annot"><a href="System.Directory.html#matchTrailingSeparator"><span class="hs-identifier hs-type">matchTrailingSeparator</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-945"></span><span id="matchTrailingSeparator"><span class="annot"><span class="annottext">matchTrailingSeparator :: FilePath -&gt; FilePath -&gt; FilePath
</span><a href="System.Directory.html#matchTrailingSeparator"><span class="hs-identifier hs-var hs-var">matchTrailingSeparator</span></a></span></span><span> </span><span id="local-6989586621679048671"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048671"><span class="hs-identifier hs-var">path</span></a></span></span><span>
</span><span id="line-946"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Bool
</span><a href="../../filepath/src/System.FilePath.Windows.html#hasTrailingPathSeparator"><span class="hs-identifier hs-var">hasTrailingPathSeparator</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048671"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#addTrailingPathSeparator"><span class="hs-identifier hs-var">addTrailingPathSeparator</span></a></span><span>
</span><span id="line-947"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#dropTrailingPathSeparator"><span class="hs-identifier hs-var">dropTrailingPathSeparator</span></a></span><span>
</span><span id="line-948"></span><span>
</span><span id="line-949"></span><span class="hs-comment">-- | Construct a path relative to the current directory, similar to</span><span>
</span><span id="line-950"></span><span class="hs-comment">-- 'makeRelative'.</span><span>
</span><span id="line-951"></span><span class="hs-comment">--</span><span>
</span><span id="line-952"></span><span class="hs-comment">-- The operation may fail with the same exceptions as 'getCurrentDirectory'.</span><span>
</span><span id="line-953"></span><span class="annot"><a href="System.Directory.html#makeRelativeToCurrentDirectory"><span class="hs-identifier hs-type">makeRelativeToCurrentDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-954"></span><span id="makeRelativeToCurrentDirectory"><span class="annot"><span class="annottext">makeRelativeToCurrentDirectory :: FilePath -&gt; IO FilePath
</span><a href="System.Directory.html#makeRelativeToCurrentDirectory"><span class="hs-identifier hs-var hs-var">makeRelativeToCurrentDirectory</span></a></span></span><span> </span><span id="local-6989586621679048670"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048670"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-955"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#makeRelative"><span class="hs-operator hs-var">`makeRelative`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048670"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath) -&gt; IO FilePath -&gt; IO FilePath
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IO FilePath
</span><a href="System.Directory.html#getCurrentDirectory"><span class="hs-identifier hs-var">getCurrentDirectory</span></a></span><span>
</span><span id="line-956"></span><span>
</span><span id="line-957"></span><span class="hs-comment">-- | Given the name or path of an executable file, 'findExecutable' searches</span><span>
</span><span id="line-958"></span><span class="hs-comment">-- for such a file in a list of system-defined locations, which generally</span><span>
</span><span id="line-959"></span><span class="hs-comment">-- includes @PATH@ and possibly more.  The full path to the executable is</span><span>
</span><span id="line-960"></span><span class="hs-comment">-- returned if found.  For example, @(findExecutable \&quot;ghc\&quot;)@ would normally</span><span>
</span><span id="line-961"></span><span class="hs-comment">-- give you the path to GHC.</span><span>
</span><span id="line-962"></span><span class="hs-comment">--</span><span>
</span><span id="line-963"></span><span class="hs-comment">-- The path returned by @'findExecutable' name@ corresponds to the program</span><span>
</span><span id="line-964"></span><span class="hs-comment">-- that would be executed by</span><span>
</span><span id="line-965"></span><span class="hs-comment">-- @&lt;http://hackage.haskell.org/package/process/docs/System-Process.html#v:createProcess createProcess&gt;@</span><span>
</span><span id="line-966"></span><span class="hs-comment">-- when passed the same string (as a @RawCommand@, not a @ShellCommand@),</span><span>
</span><span id="line-967"></span><span class="hs-comment">-- provided that @name@ is not a relative path with more than one segment.</span><span>
</span><span id="line-968"></span><span class="hs-comment">--</span><span>
</span><span id="line-969"></span><span class="hs-comment">-- On Windows, 'findExecutable' calls the Win32 function</span><span>
</span><span id="line-970"></span><span class="hs-comment">-- @&lt;https://msdn.microsoft.com/en-us/library/aa365527.aspx SearchPath&gt;@,</span><span>
</span><span id="line-971"></span><span class="hs-comment">-- which may search other places before checking the directories in the @PATH@</span><span>
</span><span id="line-972"></span><span class="hs-comment">-- environment variable.  Where it actually searches depends on registry</span><span>
</span><span id="line-973"></span><span class="hs-comment">-- settings, but notably includes the directory containing the current</span><span>
</span><span id="line-974"></span><span class="hs-comment">-- executable.</span><span>
</span><span id="line-975"></span><span class="hs-comment">--</span><span>
</span><span id="line-976"></span><span class="hs-comment">-- On non-Windows platforms, the behavior is equivalent to 'findFileWith'</span><span>
</span><span id="line-977"></span><span class="hs-comment">-- using the search directories from the @PATH@ environment variable and</span><span>
</span><span id="line-978"></span><span class="hs-comment">-- testing each file for executable permissions.  Details can be found in the</span><span>
</span><span id="line-979"></span><span class="hs-comment">-- documentation of 'findFileWith'.</span><span>
</span><span id="line-980"></span><span class="annot"><a href="System.Directory.html#findExecutable"><span class="hs-identifier hs-type">findExecutable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-981"></span><span id="findExecutable"><span class="annot"><span class="annottext">findExecutable :: FilePath -&gt; IO (Maybe FilePath)
</span><a href="System.Directory.html#findExecutable"><span class="hs-identifier hs-var hs-var">findExecutable</span></a></span></span><span> </span><span id="local-6989586621679048669"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048669"><span class="hs-identifier hs-var">binary</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-982"></span><span>  </span><span class="annot"><span class="annottext">ListT IO FilePath -&gt; IO (Maybe FilePath)
forall (m :: * -&gt; *) a. Functor m =&gt; ListT m a -&gt; m (Maybe a)
</span><a href="System.Directory.Internal.Common.html#listTHead"><span class="hs-identifier hs-var">listTHead</span></a></span><span>
</span><span id="line-983"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([FilePath] -&gt; FilePath -&gt; ListT IO FilePath)
-&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.Internal.Windows.html#findExecutablesLazyInternal"><span class="hs-identifier hs-var">findExecutablesLazyInternal</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath] -&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.html#findExecutablesInDirectoriesLazy"><span class="hs-identifier hs-var">findExecutablesInDirectoriesLazy</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048669"><span class="hs-identifier hs-var">binary</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-984"></span><span>
</span><span id="line-985"></span><span class="hs-comment">-- | Search for executable files in a list of system-defined locations, which</span><span>
</span><span id="line-986"></span><span class="hs-comment">-- generally includes @PATH@ and possibly more.</span><span>
</span><span id="line-987"></span><span class="hs-comment">--</span><span>
</span><span id="line-988"></span><span class="hs-comment">-- On Windows, this /only returns the first ocurrence/, if any.  Its behavior</span><span>
</span><span id="line-989"></span><span class="hs-comment">-- is therefore equivalent to 'findExecutable'.</span><span>
</span><span id="line-990"></span><span class="hs-comment">--</span><span>
</span><span id="line-991"></span><span class="hs-comment">-- On non-Windows platforms, the behavior is equivalent to</span><span>
</span><span id="line-992"></span><span class="hs-comment">-- 'findExecutablesInDirectories' using the search directories from the @PATH@</span><span>
</span><span id="line-993"></span><span class="hs-comment">-- environment variable.  Details can be found in the documentation of</span><span>
</span><span id="line-994"></span><span class="hs-comment">-- 'findExecutablesInDirectories'.</span><span>
</span><span id="line-995"></span><span class="hs-comment">--</span><span>
</span><span id="line-996"></span><span class="hs-comment">-- @since 1.2.2.0</span><span>
</span><span id="line-997"></span><span class="annot"><a href="System.Directory.html#findExecutables"><span class="hs-identifier hs-type">findExecutables</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-998"></span><span id="findExecutables"><span class="annot"><span class="annottext">findExecutables :: FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#findExecutables"><span class="hs-identifier hs-var hs-var">findExecutables</span></a></span></span><span> </span><span id="local-6989586621679048665"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048665"><span class="hs-identifier hs-var">binary</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-999"></span><span>  </span><span class="annot"><span class="annottext">ListT IO FilePath -&gt; IO [FilePath]
forall (m :: * -&gt; *) a. Monad m =&gt; ListT m a -&gt; m [a]
</span><a href="System.Directory.Internal.Common.html#listTToList"><span class="hs-identifier hs-var">listTToList</span></a></span><span>
</span><span id="line-1000"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([FilePath] -&gt; FilePath -&gt; ListT IO FilePath)
-&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.Internal.Windows.html#findExecutablesLazyInternal"><span class="hs-identifier hs-var">findExecutablesLazyInternal</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath] -&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.html#findExecutablesInDirectoriesLazy"><span class="hs-identifier hs-var">findExecutablesInDirectoriesLazy</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048665"><span class="hs-identifier hs-var">binary</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1001"></span><span>
</span><span id="line-1002"></span><span class="hs-comment">-- | Given a name or path, 'findExecutable' appends the 'exeExtension' to the</span><span>
</span><span id="line-1003"></span><span class="hs-comment">-- query and searches for executable files in the list of given search</span><span>
</span><span id="line-1004"></span><span class="hs-comment">-- directories and returns all occurrences.</span><span>
</span><span id="line-1005"></span><span class="hs-comment">--</span><span>
</span><span id="line-1006"></span><span class="hs-comment">-- The behavior is equivalent to 'findFileWith' using the given search</span><span>
</span><span id="line-1007"></span><span class="hs-comment">-- directories and testing each file for executable permissions.  Details can</span><span>
</span><span id="line-1008"></span><span class="hs-comment">-- be found in the documentation of 'findFileWith'.</span><span>
</span><span id="line-1009"></span><span class="hs-comment">--</span><span>
</span><span id="line-1010"></span><span class="hs-comment">-- Unlike other similarly named functions, 'findExecutablesInDirectories' does</span><span>
</span><span id="line-1011"></span><span class="hs-comment">-- not use @SearchPath@ from the Win32 API.  The behavior of this function on</span><span>
</span><span id="line-1012"></span><span class="hs-comment">-- Windows is therefore equivalent to those on non-Windows platforms.</span><span>
</span><span id="line-1013"></span><span class="hs-comment">--</span><span>
</span><span id="line-1014"></span><span class="hs-comment">-- @since 1.2.4.0</span><span>
</span><span id="line-1015"></span><span class="annot"><a href="System.Directory.html#findExecutablesInDirectories"><span class="hs-identifier hs-type">findExecutablesInDirectories</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1016"></span><span id="findExecutablesInDirectories"><span class="annot"><span class="annottext">findExecutablesInDirectories :: [FilePath] -&gt; FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#findExecutablesInDirectories"><span class="hs-identifier hs-var hs-var">findExecutablesInDirectories</span></a></span></span><span> </span><span id="local-6989586621679048663"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048663"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679048662"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048662"><span class="hs-identifier hs-var">binary</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1017"></span><span>  </span><span class="annot"><span class="annottext">ListT IO FilePath -&gt; IO [FilePath]
forall (m :: * -&gt; *) a. Monad m =&gt; ListT m a -&gt; m [a]
</span><a href="System.Directory.Internal.Common.html#listTToList"><span class="hs-identifier hs-var">listTToList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[FilePath] -&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.html#findExecutablesInDirectoriesLazy"><span class="hs-identifier hs-var">findExecutablesInDirectoriesLazy</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048663"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048662"><span class="hs-identifier hs-var">binary</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1018"></span><span>
</span><span id="line-1019"></span><span class="annot"><a href="System.Directory.html#findExecutablesInDirectoriesLazy"><span class="hs-identifier hs-type">findExecutablesInDirectoriesLazy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#ListT"><span class="hs-identifier hs-type">ListT</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-1020"></span><span id="findExecutablesInDirectoriesLazy"><span class="annot"><span class="annottext">findExecutablesInDirectoriesLazy :: [FilePath] -&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.html#findExecutablesInDirectoriesLazy"><span class="hs-identifier hs-var hs-var">findExecutablesInDirectoriesLazy</span></a></span></span><span> </span><span id="local-6989586621679048661"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048661"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679048660"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048660"><span class="hs-identifier hs-var">binary</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1021"></span><span>  </span><span class="annot"><span class="annottext">(FilePath -&gt; IO Bool)
-&gt; [FilePath] -&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.html#findFilesWithLazy"><span class="hs-identifier hs-var">findFilesWithLazy</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="System.Directory.html#isExecutable"><span class="hs-identifier hs-var">isExecutable</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048661"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048660"><span class="hs-identifier hs-var">binary</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="System.Directory.html#exeExtension"><span class="hs-identifier hs-var">exeExtension</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1022"></span><span>
</span><span id="line-1023"></span><span class="hs-comment">-- | Test whether a file has executable permissions.</span><span>
</span><span id="line-1024"></span><span class="annot"><a href="System.Directory.html#isExecutable"><span class="hs-identifier hs-type">isExecutable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1025"></span><span id="isExecutable"><span class="annot"><span class="annottext">isExecutable :: FilePath -&gt; IO Bool
</span><a href="System.Directory.html#isExecutable"><span class="hs-identifier hs-var hs-var">isExecutable</span></a></span></span><span> </span><span id="local-6989586621679048657"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048657"><span class="hs-identifier hs-var">file</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Permissions -&gt; Bool
</span><a href="System.Directory.Internal.Common.html#executable"><span class="hs-identifier hs-var hs-var">executable</span></a></span><span> </span><span class="annot"><span class="annottext">(Permissions -&gt; Bool) -&gt; IO Permissions -&gt; IO Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Permissions
</span><a href="System.Directory.html#getPermissions"><span class="hs-identifier hs-var">getPermissions</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048657"><span class="hs-identifier hs-var">file</span></a></span><span>
</span><span id="line-1026"></span><span>
</span><span id="line-1027"></span><span class="hs-comment">-- | Search through the given list of directories for the given file.</span><span>
</span><span id="line-1028"></span><span class="hs-comment">--</span><span>
</span><span id="line-1029"></span><span class="hs-comment">-- The behavior is equivalent to 'findFileWith', returning only the first</span><span>
</span><span id="line-1030"></span><span class="hs-comment">-- occurrence.  Details can be found in the documentation of 'findFileWith'.</span><span>
</span><span id="line-1031"></span><span class="annot"><a href="System.Directory.html#findFile"><span class="hs-identifier hs-type">findFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1032"></span><span id="findFile"><span class="annot"><span class="annottext">findFile :: [FilePath] -&gt; FilePath -&gt; IO (Maybe FilePath)
</span><a href="System.Directory.html#findFile"><span class="hs-identifier hs-var hs-var">findFile</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO Bool)
-&gt; [FilePath] -&gt; FilePath -&gt; IO (Maybe FilePath)
</span><a href="System.Directory.html#findFileWith"><span class="hs-identifier hs-var">findFileWith</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>
</span><span id="line-1033"></span><span>
</span><span id="line-1034"></span><span class="hs-comment">-- | Search through the given list of directories for the given file and</span><span>
</span><span id="line-1035"></span><span class="hs-comment">-- returns all paths where the given file exists.</span><span>
</span><span id="line-1036"></span><span class="hs-comment">--</span><span>
</span><span id="line-1037"></span><span class="hs-comment">-- The behavior is equivalent to 'findFilesWith'.  Details can be found in the</span><span>
</span><span id="line-1038"></span><span class="hs-comment">-- documentation of 'findFilesWith'.</span><span>
</span><span id="line-1039"></span><span class="hs-comment">--</span><span>
</span><span id="line-1040"></span><span class="hs-comment">-- @since 1.2.1.0</span><span>
</span><span id="line-1041"></span><span class="annot"><a href="System.Directory.html#findFiles"><span class="hs-identifier hs-type">findFiles</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1042"></span><span id="findFiles"><span class="annot"><span class="annottext">findFiles :: [FilePath] -&gt; FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#findFiles"><span class="hs-identifier hs-var hs-var">findFiles</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO Bool) -&gt; [FilePath] -&gt; FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#findFilesWith"><span class="hs-identifier hs-var">findFilesWith</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>
</span><span id="line-1043"></span><span>
</span><span id="line-1044"></span><span class="hs-comment">-- | Search through a given list of directories for a file that has the given</span><span>
</span><span id="line-1045"></span><span class="hs-comment">-- name and satisfies the given predicate and return the path of the first</span><span>
</span><span id="line-1046"></span><span class="hs-comment">-- occurrence.  The directories are checked in a left-to-right order.</span><span>
</span><span id="line-1047"></span><span class="hs-comment">--</span><span>
</span><span id="line-1048"></span><span class="hs-comment">-- This is essentially a more performant version of 'findFilesWith' that</span><span>
</span><span id="line-1049"></span><span class="hs-comment">-- always returns the first result, if any.  Details can be found in the</span><span>
</span><span id="line-1050"></span><span class="hs-comment">-- documentation of 'findFilesWith'.</span><span>
</span><span id="line-1051"></span><span class="hs-comment">--</span><span>
</span><span id="line-1052"></span><span class="hs-comment">-- @since 1.2.6.0</span><span>
</span><span id="line-1053"></span><span class="annot"><a href="System.Directory.html#findFileWith"><span class="hs-identifier hs-type">findFileWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1054"></span><span id="findFileWith"><span class="annot"><span class="annottext">findFileWith :: (FilePath -&gt; IO Bool)
-&gt; [FilePath] -&gt; FilePath -&gt; IO (Maybe FilePath)
</span><a href="System.Directory.html#findFileWith"><span class="hs-identifier hs-var hs-var">findFileWith</span></a></span></span><span> </span><span id="local-6989586621679048656"><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="#local-6989586621679048656"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679048655"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048655"><span class="hs-identifier hs-var">ds</span></a></span></span><span> </span><span id="local-6989586621679048654"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048654"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ListT IO FilePath -&gt; IO (Maybe FilePath)
forall (m :: * -&gt; *) a. Functor m =&gt; ListT m a -&gt; m (Maybe a)
</span><a href="System.Directory.Internal.Common.html#listTHead"><span class="hs-identifier hs-var">listTHead</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(FilePath -&gt; IO Bool)
-&gt; [FilePath] -&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.html#findFilesWithLazy"><span class="hs-identifier hs-var">findFilesWithLazy</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="#local-6989586621679048656"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048655"><span class="hs-identifier hs-var">ds</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048654"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1055"></span><span>
</span><span id="line-1056"></span><span class="hs-comment">-- | @findFilesWith predicate dirs name@ searches through the list of</span><span>
</span><span id="line-1057"></span><span class="hs-comment">-- directories (@dirs@) for files that have the given @name@ and satisfy the</span><span>
</span><span id="line-1058"></span><span class="hs-comment">-- given @predicate@ ands return the paths of those files.  The directories</span><span>
</span><span id="line-1059"></span><span class="hs-comment">-- are checked in a left-to-right order and the paths are returned in the same</span><span>
</span><span id="line-1060"></span><span class="hs-comment">-- order.</span><span>
</span><span id="line-1061"></span><span class="hs-comment">--</span><span>
</span><span id="line-1062"></span><span class="hs-comment">-- If the @name@ is a relative path, then for every search directory @dir@,</span><span>
</span><span id="line-1063"></span><span class="hs-comment">-- the function checks whether @dir '&lt;/&gt;' name@ exists and satisfies the</span><span>
</span><span id="line-1064"></span><span class="hs-comment">-- predicate.  If so, @dir '&lt;/&gt;' name@ is returned as one of the results.  In</span><span>
</span><span id="line-1065"></span><span class="hs-comment">-- other words, the returned paths can be either relative or absolute</span><span>
</span><span id="line-1066"></span><span class="hs-comment">-- depending on the search directories were used.  If there are no search</span><span>
</span><span id="line-1067"></span><span class="hs-comment">-- directories, no results are ever returned.</span><span>
</span><span id="line-1068"></span><span class="hs-comment">--</span><span>
</span><span id="line-1069"></span><span class="hs-comment">-- If the @name@ is an absolute path, then the function will return a single</span><span>
</span><span id="line-1070"></span><span class="hs-comment">-- result if the file exists and satisfies the predicate and no results</span><span>
</span><span id="line-1071"></span><span class="hs-comment">-- otherwise.  This is irrespective of what search directories were given.</span><span>
</span><span id="line-1072"></span><span class="hs-comment">--</span><span>
</span><span id="line-1073"></span><span class="hs-comment">-- @since 1.2.1.0</span><span>
</span><span id="line-1074"></span><span class="annot"><a href="System.Directory.html#findFilesWith"><span class="hs-identifier hs-type">findFilesWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1075"></span><span id="findFilesWith"><span class="annot"><span class="annottext">findFilesWith :: (FilePath -&gt; IO Bool) -&gt; [FilePath] -&gt; FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#findFilesWith"><span class="hs-identifier hs-var hs-var">findFilesWith</span></a></span></span><span> </span><span id="local-6989586621679048653"><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="#local-6989586621679048653"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679048652"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048652"><span class="hs-identifier hs-var">ds</span></a></span></span><span> </span><span id="local-6989586621679048651"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048651"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ListT IO FilePath -&gt; IO [FilePath]
forall (m :: * -&gt; *) a. Monad m =&gt; ListT m a -&gt; m [a]
</span><a href="System.Directory.Internal.Common.html#listTToList"><span class="hs-identifier hs-var">listTToList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(FilePath -&gt; IO Bool)
-&gt; [FilePath] -&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.html#findFilesWithLazy"><span class="hs-identifier hs-var">findFilesWithLazy</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="#local-6989586621679048653"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048652"><span class="hs-identifier hs-var">ds</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048651"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1076"></span><span>
</span><span id="line-1077"></span><span class="annot"><a href="System.Directory.html#findFilesWithLazy"><span class="hs-identifier hs-type">findFilesWithLazy</span></a></span><span>
</span><span id="line-1078"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#ListT"><span class="hs-identifier hs-type">ListT</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-1079"></span><span id="findFilesWithLazy"><span class="annot"><span class="annottext">findFilesWithLazy :: (FilePath -&gt; IO Bool)
-&gt; [FilePath] -&gt; FilePath -&gt; ListT IO FilePath
</span><a href="System.Directory.html#findFilesWithLazy"><span class="hs-identifier hs-var hs-var">findFilesWithLazy</span></a></span></span><span> </span><span id="local-6989586621679048650"><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="#local-6989586621679048650"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679048649"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048649"><span class="hs-identifier hs-var">dirs</span></a></span></span><span> </span><span id="local-6989586621679048648"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048648"><span class="hs-identifier hs-var">path</span></a></span></span><span>
</span><span id="line-1080"></span><span>  </span><span class="hs-comment">-- make sure absolute paths are handled properly irrespective of 'dirs'</span><span>
</span><span id="line-1081"></span><span>  </span><span class="hs-comment">-- https://github.com/haskell/directory/issues/72</span><span>
</span><span id="line-1082"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Bool
</span><a href="../../filepath/src/System.FilePath.Windows.html#isAbsolute"><span class="hs-identifier hs-var">isAbsolute</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048648"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Maybe (FilePath, ListT IO FilePath)) -&gt; ListT IO FilePath
forall (m :: * -&gt; *) a. m (Maybe (a, ListT m a)) -&gt; ListT m a
</span><a href="System.Directory.Internal.Common.html#ListT"><span class="hs-identifier hs-var">ListT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[FilePath] -&gt; IO (Maybe (FilePath, ListT IO FilePath))
</span><a href="#local-6989586621679048646"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;&quot;</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1083"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Maybe (FilePath, ListT IO FilePath)) -&gt; ListT IO FilePath
forall (m :: * -&gt; *) a. m (Maybe (a, ListT m a)) -&gt; ListT m a
</span><a href="System.Directory.Internal.Common.html#ListT"><span class="hs-identifier hs-var">ListT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[FilePath] -&gt; IO (Maybe (FilePath, ListT IO FilePath))
</span><a href="#local-6989586621679048646"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048649"><span class="hs-identifier hs-var">dirs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1084"></span><span>
</span><span id="line-1085"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1086"></span><span>
</span><span id="line-1087"></span><span>    </span><span id="local-6989586621679048646"><span class="annot"><span class="annottext">find :: [FilePath] -&gt; IO (Maybe (FilePath, ListT IO FilePath))
</span><a href="#local-6989586621679048646"><span class="hs-identifier hs-var hs-var">find</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (FilePath, ListT IO FilePath)
-&gt; IO (Maybe (FilePath, ListT IO FilePath))
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (FilePath, ListT IO FilePath)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1088"></span><span>    </span><span class="annot"><a href="#local-6989586621679048646"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679048641"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048641"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621679048640"><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048640"><span class="hs-identifier hs-var">ds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1089"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679048639"><span class="annot"><span class="annottext">p :: FilePath
</span><a href="#local-6989586621679048639"><span class="hs-identifier hs-var hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048641"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048648"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1090"></span><span>      </span><span id="local-6989586621679048638"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048638"><span class="hs-identifier hs-var">found</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="System.Directory.html#doesFileExist"><span class="hs-identifier hs-var">doesFileExist</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048639"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">IO Bool -&gt; IO Bool -&gt; IO Bool
forall (m :: * -&gt; *). Monad m =&gt; m Bool -&gt; m Bool -&gt; m Bool
</span><a href="System.Directory.Internal.Common.html#andM"><span class="hs-operator hs-var">`andM`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="#local-6989586621679048650"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048639"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-1091"></span><span>      </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679048638"><span class="hs-identifier hs-var">found</span></a></span><span>
</span><span id="line-1092"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe (FilePath, ListT IO FilePath)
-&gt; IO (Maybe (FilePath, ListT IO FilePath))
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(FilePath, ListT IO FilePath)
-&gt; Maybe (FilePath, ListT IO FilePath)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048639"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">IO (Maybe (FilePath, ListT IO FilePath)) -&gt; ListT IO FilePath
forall (m :: * -&gt; *) a. m (Maybe (a, ListT m a)) -&gt; ListT m a
</span><a href="System.Directory.Internal.Common.html#ListT"><span class="hs-identifier hs-var">ListT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[FilePath] -&gt; IO (Maybe (FilePath, ListT IO FilePath))
</span><a href="#local-6989586621679048646"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048640"><span class="hs-identifier hs-var">ds</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1093"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[FilePath] -&gt; IO (Maybe (FilePath, ListT IO FilePath))
</span><a href="#local-6989586621679048646"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">[FilePath]
</span><a href="#local-6989586621679048640"><span class="hs-identifier hs-var">ds</span></a></span><span>
</span><span id="line-1094"></span><span>
</span><span id="line-1095"></span><span class="hs-comment">-- | Filename extension for executable files (including the dot if any)</span><span>
</span><span id="line-1096"></span><span class="hs-comment">--   (usually @\&quot;\&quot;@ on POSIX systems and @\&quot;.exe\&quot;@ on Windows or OS\/2).</span><span>
</span><span id="line-1097"></span><span class="hs-comment">--</span><span>
</span><span id="line-1098"></span><span class="hs-comment">-- @since 1.2.4.0</span><span>
</span><span id="line-1099"></span><span class="annot"><a href="System.Directory.html#exeExtension"><span class="hs-identifier hs-type">exeExtension</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-1100"></span><span id="exeExtension"><span class="annot"><span class="annottext">exeExtension :: FilePath
</span><a href="System.Directory.html#exeExtension"><span class="hs-identifier hs-var hs-var">exeExtension</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="System.Directory.Internal.Windows.html#exeExtensionInternal"><span class="hs-identifier hs-var">exeExtensionInternal</span></a></span><span>
</span><span id="line-1101"></span><span>
</span><span id="line-1102"></span><span class="hs-comment">-- | Similar to 'listDirectory', but always includes the special entries (@.@</span><span>
</span><span id="line-1103"></span><span class="hs-comment">-- and @..@).  (This applies to Windows as well.)</span><span>
</span><span id="line-1104"></span><span class="hs-comment">--</span><span>
</span><span id="line-1105"></span><span class="hs-comment">-- The operation may fail with the same exceptions as 'listDirectory'.</span><span>
</span><span id="line-1106"></span><span class="annot"><a href="System.Directory.html#getDirectoryContents"><span class="hs-identifier hs-type">getDirectoryContents</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1107"></span><span id="getDirectoryContents"><span class="annot"><span class="annottext">getDirectoryContents :: FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#getDirectoryContents"><span class="hs-identifier hs-var hs-var">getDirectoryContents</span></a></span></span><span> </span><span id="local-6989586621679048635"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048635"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1108"></span><span>  </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#ioeSetFileName"><span class="hs-operator hs-var">`ioeSetFileName`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048635"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; (IOError -&gt; IOError) -&gt; IOError -&gt; IOError
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-1109"></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getDirectoryContents&quot;</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO [FilePath] -&gt; IO [FilePath]
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1110"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.Internal.Windows.html#getDirectoryContentsInternal"><span class="hs-identifier hs-var">getDirectoryContentsInternal</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048635"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1111"></span><span>
</span><span id="line-1112"></span><span class="hs-comment">-- | @'listDirectory' dir@ returns a list of /all/ entries in /dir/ without</span><span>
</span><span id="line-1113"></span><span class="hs-comment">-- the special entries (@.@ and @..@).</span><span>
</span><span id="line-1114"></span><span class="hs-comment">--</span><span>
</span><span id="line-1115"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-1116"></span><span class="hs-comment">--</span><span>
</span><span id="line-1117"></span><span class="hs-comment">-- * @HardwareFault@</span><span>
</span><span id="line-1118"></span><span class="hs-comment">--   A physical I\/O error has occurred.</span><span>
</span><span id="line-1119"></span><span class="hs-comment">--   @[EIO]@</span><span>
</span><span id="line-1120"></span><span class="hs-comment">--</span><span>
</span><span id="line-1121"></span><span class="hs-comment">-- * @InvalidArgument@</span><span>
</span><span id="line-1122"></span><span class="hs-comment">--   The operand is not a valid directory name.</span><span>
</span><span id="line-1123"></span><span class="hs-comment">--   @[ENAMETOOLONG, ELOOP]@</span><span>
</span><span id="line-1124"></span><span class="hs-comment">--</span><span>
</span><span id="line-1125"></span><span class="hs-comment">-- * 'isDoesNotExistError'</span><span>
</span><span id="line-1126"></span><span class="hs-comment">--   The directory does not exist.</span><span>
</span><span id="line-1127"></span><span class="hs-comment">--   @[ENOENT, ENOTDIR]@</span><span>
</span><span id="line-1128"></span><span class="hs-comment">--</span><span>
</span><span id="line-1129"></span><span class="hs-comment">-- * 'isPermissionError'</span><span>
</span><span id="line-1130"></span><span class="hs-comment">--   The process has insufficient privileges to perform the operation.</span><span>
</span><span id="line-1131"></span><span class="hs-comment">--   @[EACCES]@</span><span>
</span><span id="line-1132"></span><span class="hs-comment">--</span><span>
</span><span id="line-1133"></span><span class="hs-comment">-- * 'System.IO.isFullError'</span><span>
</span><span id="line-1134"></span><span class="hs-comment">--   Insufficient resources are available to perform the operation.</span><span>
</span><span id="line-1135"></span><span class="hs-comment">--   @[EMFILE, ENFILE]@</span><span>
</span><span id="line-1136"></span><span class="hs-comment">--</span><span>
</span><span id="line-1137"></span><span class="hs-comment">-- * @InappropriateType@</span><span>
</span><span id="line-1138"></span><span class="hs-comment">--   The path refers to an existing non-directory object.</span><span>
</span><span id="line-1139"></span><span class="hs-comment">--   @[ENOTDIR]@</span><span>
</span><span id="line-1140"></span><span class="hs-comment">--</span><span>
</span><span id="line-1141"></span><span class="hs-comment">-- @since 1.2.5.0</span><span>
</span><span id="line-1142"></span><span class="hs-comment">--</span><span>
</span><span id="line-1143"></span><span class="annot"><a href="System.Directory.html#listDirectory"><span class="hs-identifier hs-type">listDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1144"></span><span id="listDirectory"><span class="annot"><span class="annottext">listDirectory :: FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#listDirectory"><span class="hs-identifier hs-var hs-var">listDirectory</span></a></span></span><span> </span><span id="local-6989586621679048633"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048633"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; Bool) -&gt; [FilePath] -&gt; [FilePath]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Bool
</span><a href="#local-6989586621679048632"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">([FilePath] -&gt; [FilePath]) -&gt; IO [FilePath] -&gt; IO [FilePath]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO [FilePath]
</span><a href="System.Directory.html#getDirectoryContents"><span class="hs-identifier hs-var">getDirectoryContents</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048633"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1145"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679048632"><span class="annot"><span class="annottext">f :: FilePath -&gt; Bool
</span><a href="#local-6989586621679048632"><span class="hs-identifier hs-var hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679048626"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048626"><span class="hs-identifier hs-var">filename</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048626"><span class="hs-identifier hs-var">filename</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;.&quot;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048626"><span class="hs-identifier hs-var">filename</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;..&quot;</span></span><span>
</span><span id="line-1146"></span><span>
</span><span id="line-1147"></span><span class="hs-comment">-- | Obtain the current working directory as an absolute path.</span><span>
</span><span id="line-1148"></span><span class="hs-comment">--</span><span>
</span><span id="line-1149"></span><span class="hs-comment">-- In a multithreaded program, the current working directory is a global state</span><span>
</span><span id="line-1150"></span><span class="hs-comment">-- shared among all threads of the process.  Therefore, when performing</span><span>
</span><span id="line-1151"></span><span class="hs-comment">-- filesystem operations from multiple threads, it is highly recommended to</span><span>
</span><span id="line-1152"></span><span class="hs-comment">-- use absolute rather than relative paths (see: 'makeAbsolute').</span><span>
</span><span id="line-1153"></span><span class="hs-comment">--</span><span>
</span><span id="line-1154"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-1155"></span><span class="hs-comment">--</span><span>
</span><span id="line-1156"></span><span class="hs-comment">-- * @HardwareFault@</span><span>
</span><span id="line-1157"></span><span class="hs-comment">-- A physical I\/O error has occurred.</span><span>
</span><span id="line-1158"></span><span class="hs-comment">-- @[EIO]@</span><span>
</span><span id="line-1159"></span><span class="hs-comment">--</span><span>
</span><span id="line-1160"></span><span class="hs-comment">-- * 'isDoesNotExistError'</span><span>
</span><span id="line-1161"></span><span class="hs-comment">-- There is no path referring to the working directory.</span><span>
</span><span id="line-1162"></span><span class="hs-comment">-- @[EPERM, ENOENT, ESTALE...]@</span><span>
</span><span id="line-1163"></span><span class="hs-comment">--</span><span>
</span><span id="line-1164"></span><span class="hs-comment">-- * 'isPermissionError'</span><span>
</span><span id="line-1165"></span><span class="hs-comment">-- The process has insufficient privileges to perform the operation.</span><span>
</span><span id="line-1166"></span><span class="hs-comment">-- @[EACCES]@</span><span>
</span><span id="line-1167"></span><span class="hs-comment">--</span><span>
</span><span id="line-1168"></span><span class="hs-comment">-- * 'System.IO.isFullError'</span><span>
</span><span id="line-1169"></span><span class="hs-comment">-- Insufficient resources are available to perform the operation.</span><span>
</span><span id="line-1170"></span><span class="hs-comment">--</span><span>
</span><span id="line-1171"></span><span class="hs-comment">-- * @UnsupportedOperation@</span><span>
</span><span id="line-1172"></span><span class="hs-comment">-- The operating system has no notion of current working directory.</span><span>
</span><span id="line-1173"></span><span class="hs-comment">--</span><span>
</span><span id="line-1174"></span><span class="annot"><a href="System.Directory.html#getCurrentDirectory"><span class="hs-identifier hs-type">getCurrentDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-1175"></span><span id="getCurrentDirectory"><span class="annot"><span class="annottext">getCurrentDirectory :: IO FilePath
</span><a href="System.Directory.html#getCurrentDirectory"><span class="hs-identifier hs-var hs-var">getCurrentDirectory</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1176"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getCurrentDirectory&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO FilePath -&gt; IO FilePath
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1177"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; (IOError -&gt; Bool) -&gt; IO FilePath -&gt; IO FilePath
forall a. FilePath -&gt; (IOError -&gt; Bool) -&gt; IO a -&gt; IO a
</span><a href="System.Directory.Internal.Common.html#specializeErrorString"><span class="hs-identifier hs-var">specializeErrorString</span></a></span><span>
</span><span id="line-1178"></span><span>      </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;Current working directory no longer exists&quot;</span></span><span>
</span><span id="line-1179"></span><span>      </span><span class="annot"><span class="annottext">IOError -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isDoesNotExistError"><span class="hs-identifier hs-var">isDoesNotExistError</span></a></span><span>
</span><span id="line-1180"></span><span>      </span><span class="annot"><span class="annottext">IO FilePath
</span><a href="System.Directory.Internal.Windows.html#getCurrentDirectoryInternal"><span class="hs-identifier hs-var">getCurrentDirectoryInternal</span></a></span><span>
</span><span id="line-1181"></span><span>
</span><span id="line-1182"></span><span class="hs-comment">-- | Change the working directory to the given path.</span><span>
</span><span id="line-1183"></span><span class="hs-comment">--</span><span>
</span><span id="line-1184"></span><span class="hs-comment">-- In a multithreaded program, the current working directory is a global state</span><span>
</span><span id="line-1185"></span><span class="hs-comment">-- shared among all threads of the process.  Therefore, when performing</span><span>
</span><span id="line-1186"></span><span class="hs-comment">-- filesystem operations from multiple threads, it is highly recommended to</span><span>
</span><span id="line-1187"></span><span class="hs-comment">-- use absolute rather than relative paths (see: 'makeAbsolute').</span><span>
</span><span id="line-1188"></span><span class="hs-comment">--</span><span>
</span><span id="line-1189"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-1190"></span><span class="hs-comment">--</span><span>
</span><span id="line-1191"></span><span class="hs-comment">-- * @HardwareFault@</span><span>
</span><span id="line-1192"></span><span class="hs-comment">-- A physical I\/O error has occurred.</span><span>
</span><span id="line-1193"></span><span class="hs-comment">-- @[EIO]@</span><span>
</span><span id="line-1194"></span><span class="hs-comment">--</span><span>
</span><span id="line-1195"></span><span class="hs-comment">-- * @InvalidArgument@</span><span>
</span><span id="line-1196"></span><span class="hs-comment">-- The operand is not a valid directory name.</span><span>
</span><span id="line-1197"></span><span class="hs-comment">-- @[ENAMETOOLONG, ELOOP]@</span><span>
</span><span id="line-1198"></span><span class="hs-comment">--</span><span>
</span><span id="line-1199"></span><span class="hs-comment">-- * 'isDoesNotExistError'</span><span>
</span><span id="line-1200"></span><span class="hs-comment">-- The directory does not exist.</span><span>
</span><span id="line-1201"></span><span class="hs-comment">-- @[ENOENT, ENOTDIR]@</span><span>
</span><span id="line-1202"></span><span class="hs-comment">--</span><span>
</span><span id="line-1203"></span><span class="hs-comment">-- * 'isPermissionError'</span><span>
</span><span id="line-1204"></span><span class="hs-comment">-- The process has insufficient privileges to perform the operation.</span><span>
</span><span id="line-1205"></span><span class="hs-comment">-- @[EACCES]@</span><span>
</span><span id="line-1206"></span><span class="hs-comment">--</span><span>
</span><span id="line-1207"></span><span class="hs-comment">-- * @UnsupportedOperation@</span><span>
</span><span id="line-1208"></span><span class="hs-comment">-- The operating system has no notion of current working directory, or the</span><span>
</span><span id="line-1209"></span><span class="hs-comment">-- working directory cannot be dynamically changed.</span><span>
</span><span id="line-1210"></span><span class="hs-comment">--</span><span>
</span><span id="line-1211"></span><span class="hs-comment">-- * @InappropriateType@</span><span>
</span><span id="line-1212"></span><span class="hs-comment">-- The path refers to an existing non-directory object.</span><span>
</span><span id="line-1213"></span><span class="hs-comment">-- @[ENOTDIR]@</span><span>
</span><span id="line-1214"></span><span class="hs-comment">--</span><span>
</span><span id="line-1215"></span><span class="annot"><a href="System.Directory.html#setCurrentDirectory"><span class="hs-identifier hs-type">setCurrentDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1216"></span><span id="setCurrentDirectory"><span class="annot"><span class="annottext">setCurrentDirectory :: FilePath -&gt; IO ()
</span><a href="System.Directory.html#setCurrentDirectory"><span class="hs-identifier hs-var hs-var">setCurrentDirectory</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#setCurrentDirectoryInternal"><span class="hs-identifier hs-var">setCurrentDirectoryInternal</span></a></span><span>
</span><span id="line-1217"></span><span>
</span><span id="line-1218"></span><span class="hs-comment">-- | Run an 'IO' action with the given working directory and restore the</span><span>
</span><span id="line-1219"></span><span class="hs-comment">-- original working directory afterwards, even if the given action fails due</span><span>
</span><span id="line-1220"></span><span class="hs-comment">-- to an exception.</span><span>
</span><span id="line-1221"></span><span class="hs-comment">--</span><span>
</span><span id="line-1222"></span><span class="hs-comment">-- The operation may fail with the same exceptions as 'getCurrentDirectory'</span><span>
</span><span id="line-1223"></span><span class="hs-comment">-- and 'setCurrentDirectory'.</span><span>
</span><span id="line-1224"></span><span class="hs-comment">--</span><span>
</span><span id="line-1225"></span><span class="hs-comment">-- @since 1.2.3.0</span><span>
</span><span id="line-1226"></span><span class="hs-comment">--</span><span>
</span><span id="line-1227"></span><span id="local-6989586621679049017"><span class="annot"><a href="System.Directory.html#withCurrentDirectory"><span class="hs-identifier hs-type">withCurrentDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>  </span><span class="hs-comment">-- ^ Directory to execute in</span><span>
</span><span id="line-1228"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679049017"><span class="hs-identifier hs-type">a</span></a></span><span>      </span><span class="hs-comment">-- ^ Action to be executed</span><span>
</span><span id="line-1229"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679049017"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1230"></span><span id="withCurrentDirectory"><span class="annot"><span class="annottext">withCurrentDirectory :: forall a. FilePath -&gt; IO a -&gt; IO a
</span><a href="System.Directory.html#withCurrentDirectory"><span class="hs-identifier hs-var hs-var">withCurrentDirectory</span></a></span></span><span> </span><span id="local-6989586621679048619"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048619"><span class="hs-identifier hs-var">dir</span></a></span></span><span> </span><span id="local-6989586621679048618"><span class="annot"><span class="annottext">IO a
</span><a href="#local-6989586621679048618"><span class="hs-identifier hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1231"></span><span>  </span><span class="annot"><span class="annottext">IO FilePath -&gt; (FilePath -&gt; IO ()) -&gt; (FilePath -&gt; IO a) -&gt; IO a
forall a b c. IO a -&gt; (a -&gt; IO b) -&gt; (a -&gt; IO c) -&gt; IO c
</span><a href="../../base/src/Control.Exception.Base.html#bracket"><span class="hs-identifier hs-var">bracket</span></a></span><span> </span><span class="annot"><span class="annottext">IO FilePath
</span><a href="System.Directory.html#getCurrentDirectory"><span class="hs-identifier hs-var">getCurrentDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#setCurrentDirectory"><span class="hs-identifier hs-var">setCurrentDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">((FilePath -&gt; IO a) -&gt; IO a) -&gt; (FilePath -&gt; IO a) -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1232"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="System.Directory.html#setCurrentDirectory"><span class="hs-identifier hs-var">setCurrentDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048619"><span class="hs-identifier hs-var">dir</span></a></span><span>
</span><span id="line-1233"></span><span>    </span><span class="annot"><span class="annottext">IO a
</span><a href="#local-6989586621679048618"><span class="hs-identifier hs-var">action</span></a></span><span>
</span><span id="line-1234"></span><span>
</span><span id="line-1235"></span><span class="hs-comment">-- | Obtain the size of a file in bytes.</span><span>
</span><span id="line-1236"></span><span class="hs-comment">--</span><span>
</span><span id="line-1237"></span><span class="hs-comment">-- @since 1.2.7.0</span><span>
</span><span id="line-1238"></span><span class="annot"><a href="System.Directory.html#getFileSize"><span class="hs-identifier hs-type">getFileSize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span>
</span><span id="line-1239"></span><span id="getFileSize"><span class="annot"><span class="annottext">getFileSize :: FilePath -&gt; IO Integer
</span><a href="System.Directory.html#getFileSize"><span class="hs-identifier hs-var hs-var">getFileSize</span></a></span></span><span> </span><span id="local-6989586621679048616"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048616"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1240"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getFileSize&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO Integer -&gt; IO Integer
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1241"></span><span>    </span><span class="annot"><span class="annottext">Metadata -&gt; Integer
</span><a href="System.Directory.Internal.Windows.html#fileSizeFromMetadata"><span class="hs-identifier hs-var">fileSizeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">(Metadata -&gt; Integer) -&gt; IO Metadata -&gt; IO Integer
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getFileMetadata"><span class="hs-identifier hs-var">getFileMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048616"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1242"></span><span>
</span><span id="line-1243"></span><span class="hs-comment">-- | Test whether the given path points to an existing filesystem object.  If</span><span>
</span><span id="line-1244"></span><span class="hs-comment">-- the user lacks necessary permissions to search the parent directories, this</span><span>
</span><span id="line-1245"></span><span class="hs-comment">-- function may return false even if the file does actually exist.</span><span>
</span><span id="line-1246"></span><span class="hs-comment">--</span><span>
</span><span id="line-1247"></span><span class="hs-comment">-- @since 1.2.7.0</span><span>
</span><span id="line-1248"></span><span class="annot"><a href="System.Directory.html#doesPathExist"><span class="hs-identifier hs-type">doesPathExist</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1249"></span><span id="doesPathExist"><span class="annot"><span class="annottext">doesPathExist :: FilePath -&gt; IO Bool
</span><a href="System.Directory.html#doesPathExist"><span class="hs-identifier hs-var hs-var">doesPathExist</span></a></span></span><span> </span><span id="local-6989586621679048614"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048614"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1250"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Metadata -&gt; IO Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; a -&gt; f b -&gt; f a
</span><a href="../../base/src/GHC.Base.html#%3C%24"><span class="hs-operator hs-var">&lt;$</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getFileMetadata"><span class="hs-identifier hs-var">getFileMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048614"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1251"></span><span>    </span><span class="annot"><span class="annottext">IO Bool -&gt; (IOError -&gt; IO Bool) -&gt; IO Bool
forall a. IO a -&gt; (IOError -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#catchIOError"><span class="hs-operator hs-var">`catchIOError`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1252"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1253"></span><span>
</span><span id="line-1254"></span><span class="hs-comment">{- |The operation 'doesDirectoryExist' returns 'True' if the argument file
exists and is either a directory or a symbolic link to a directory,
and 'False' otherwise.
-}</span><span>
</span><span id="line-1258"></span><span>
</span><span id="line-1259"></span><span class="annot"><a href="System.Directory.html#doesDirectoryExist"><span class="hs-identifier hs-type">doesDirectoryExist</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1260"></span><span id="doesDirectoryExist"><span class="annot"><span class="annottext">doesDirectoryExist :: FilePath -&gt; IO Bool
</span><a href="System.Directory.html#doesDirectoryExist"><span class="hs-identifier hs-var hs-var">doesDirectoryExist</span></a></span></span><span> </span><span id="local-6989586621679048613"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048613"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1261"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="System.Directory.html#pathIsDirectory"><span class="hs-identifier hs-var">pathIsDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048613"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1262"></span><span>    </span><span class="annot"><span class="annottext">IO Bool -&gt; (IOError -&gt; IO Bool) -&gt; IO Bool
forall a. IO a -&gt; (IOError -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#catchIOError"><span class="hs-operator hs-var">`catchIOError`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1263"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1264"></span><span>
</span><span id="line-1265"></span><span class="hs-comment">{- |The operation 'doesFileExist' returns 'True'
if the argument file exists and is not a directory, and 'False' otherwise.
-}</span><span>
</span><span id="line-1268"></span><span>
</span><span id="line-1269"></span><span class="annot"><a href="System.Directory.html#doesFileExist"><span class="hs-identifier hs-type">doesFileExist</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1270"></span><span id="doesFileExist"><span class="annot"><span class="annottext">doesFileExist :: FilePath -&gt; IO Bool
</span><a href="System.Directory.html#doesFileExist"><span class="hs-identifier hs-var hs-var">doesFileExist</span></a></span></span><span> </span><span id="local-6989586621679048612"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048612"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1271"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; IO Bool -&gt; IO Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="System.Directory.html#pathIsDirectory"><span class="hs-identifier hs-var">pathIsDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048612"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1272"></span><span>    </span><span class="annot"><span class="annottext">IO Bool -&gt; (IOError -&gt; IO Bool) -&gt; IO Bool
forall a. IO a -&gt; (IOError -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#catchIOError"><span class="hs-operator hs-var">`catchIOError`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1273"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1274"></span><span>
</span><span id="line-1275"></span><span class="annot"><a href="System.Directory.html#pathIsDirectory"><span class="hs-identifier hs-type">pathIsDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1276"></span><span id="pathIsDirectory"><span class="annot"><span class="annottext">pathIsDirectory :: FilePath -&gt; IO Bool
</span><a href="System.Directory.html#pathIsDirectory"><span class="hs-identifier hs-var hs-var">pathIsDirectory</span></a></span></span><span> </span><span id="local-6989586621679048611"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048611"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1277"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;pathIsDirectory&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO Bool -&gt; IO Bool
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1278"></span><span>    </span><span class="annot"><span class="annottext">FileType -&gt; Bool
</span><a href="System.Directory.Internal.Common.html#fileTypeIsDirectory"><span class="hs-identifier hs-var">fileTypeIsDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">(FileType -&gt; Bool) -&gt; (Metadata -&gt; FileType) -&gt; Metadata -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata -&gt; FileType
</span><a href="System.Directory.Internal.Windows.html#fileTypeFromMetadata"><span class="hs-identifier hs-var">fileTypeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">(Metadata -&gt; Bool) -&gt; IO Metadata -&gt; IO Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getFileMetadata"><span class="hs-identifier hs-var">getFileMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048611"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1279"></span><span>
</span><span id="line-1280"></span><span class="hs-comment">-- | Create a /file/ symbolic link.  The target path can be either absolute or</span><span>
</span><span id="line-1281"></span><span class="hs-comment">-- relative and need not refer to an existing file.  The order of arguments</span><span>
</span><span id="line-1282"></span><span class="hs-comment">-- follows the POSIX convention.</span><span>
</span><span id="line-1283"></span><span class="hs-comment">--</span><span>
</span><span id="line-1284"></span><span class="hs-comment">-- To remove an existing file symbolic link, use 'removeFile'.</span><span>
</span><span id="line-1285"></span><span class="hs-comment">--</span><span>
</span><span id="line-1286"></span><span class="hs-comment">-- Although the distinction between /file/ symbolic links and /directory/</span><span>
</span><span id="line-1287"></span><span class="hs-comment">-- symbolic links does not exist on POSIX systems, on Windows this is an</span><span>
</span><span id="line-1288"></span><span class="hs-comment">-- intrinsic property of every symbolic link and cannot be changed without</span><span>
</span><span id="line-1289"></span><span class="hs-comment">-- recreating the link.  A file symbolic link that actually points to a</span><span>
</span><span id="line-1290"></span><span class="hs-comment">-- directory will fail to dereference and vice versa.  Moreover, creating</span><span>
</span><span id="line-1291"></span><span class="hs-comment">-- symbolic links on Windows may require privileges unavailable to users</span><span>
</span><span id="line-1292"></span><span class="hs-comment">-- outside the Administrators group.  Portable programs that use symbolic</span><span>
</span><span id="line-1293"></span><span class="hs-comment">-- links should take both into consideration.</span><span>
</span><span id="line-1294"></span><span class="hs-comment">--</span><span>
</span><span id="line-1295"></span><span class="hs-comment">-- On Windows, the function is implemented using @CreateSymbolicLink@.  Since</span><span>
</span><span id="line-1296"></span><span class="hs-comment">-- 1.3.3.0, the @SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE@ flag is included</span><span>
</span><span id="line-1297"></span><span class="hs-comment">-- if supported by the operating system.  On POSIX, the function uses @symlink@</span><span>
</span><span id="line-1298"></span><span class="hs-comment">-- and is therefore atomic.</span><span>
</span><span id="line-1299"></span><span class="hs-comment">--</span><span>
</span><span id="line-1300"></span><span class="hs-comment">-- Windows-specific errors: This operation may fail with 'permissionErrorType'</span><span>
</span><span id="line-1301"></span><span class="hs-comment">-- if the user lacks the privileges to create symbolic links.  It may also</span><span>
</span><span id="line-1302"></span><span class="hs-comment">-- fail with 'illegalOperationErrorType' if the file system does not support</span><span>
</span><span id="line-1303"></span><span class="hs-comment">-- symbolic links.</span><span>
</span><span id="line-1304"></span><span class="hs-comment">--</span><span>
</span><span id="line-1305"></span><span class="hs-comment">-- @since 1.3.1.0</span><span>
</span><span id="line-1306"></span><span class="annot"><a href="System.Directory.html#createFileLink"><span class="hs-identifier hs-type">createFileLink</span></a></span><span>
</span><span id="line-1307"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                           </span><span class="hs-comment">-- ^ path to the target file</span><span>
</span><span id="line-1308"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                           </span><span class="hs-comment">-- ^ path of the link to be created</span><span>
</span><span id="line-1309"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1310"></span><span id="createFileLink"><span class="annot"><span class="annottext">createFileLink :: FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#createFileLink"><span class="hs-identifier hs-var hs-var">createFileLink</span></a></span></span><span> </span><span id="local-6989586621679048610"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048610"><span class="hs-identifier hs-var">target</span></a></span></span><span> </span><span id="local-6989586621679048609"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048609"><span class="hs-identifier hs-var">link</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1311"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;createFileLink&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1312"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#createSymbolicLink"><span class="hs-identifier hs-var">createSymbolicLink</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048610"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048609"><span class="hs-identifier hs-var">link</span></a></span><span>
</span><span id="line-1313"></span><span>
</span><span id="line-1314"></span><span class="hs-comment">-- | Create a /directory/ symbolic link.  The target path can be either</span><span>
</span><span id="line-1315"></span><span class="hs-comment">-- absolute or relative and need not refer to an existing directory.  The</span><span>
</span><span id="line-1316"></span><span class="hs-comment">-- order of arguments follows the POSIX convention.</span><span>
</span><span id="line-1317"></span><span class="hs-comment">--</span><span>
</span><span id="line-1318"></span><span class="hs-comment">-- To remove an existing directory symbolic link, use 'removeDirectoryLink'.</span><span>
</span><span id="line-1319"></span><span class="hs-comment">--</span><span>
</span><span id="line-1320"></span><span class="hs-comment">-- Although the distinction between /file/ symbolic links and /directory/</span><span>
</span><span id="line-1321"></span><span class="hs-comment">-- symbolic links does not exist on POSIX systems, on Windows this is an</span><span>
</span><span id="line-1322"></span><span class="hs-comment">-- intrinsic property of every symbolic link and cannot be changed without</span><span>
</span><span id="line-1323"></span><span class="hs-comment">-- recreating the link.  A file symbolic link that actually points to a</span><span>
</span><span id="line-1324"></span><span class="hs-comment">-- directory will fail to dereference and vice versa.  Moreover, creating</span><span>
</span><span id="line-1325"></span><span class="hs-comment">-- symbolic links on Windows may require privileges unavailable to users</span><span>
</span><span id="line-1326"></span><span class="hs-comment">-- outside the Administrators group.  Portable programs that use symbolic</span><span>
</span><span id="line-1327"></span><span class="hs-comment">-- links should take both into consideration.</span><span>
</span><span id="line-1328"></span><span class="hs-comment">--</span><span>
</span><span id="line-1329"></span><span class="hs-comment">-- On Windows, the function is implemented using @CreateSymbolicLink@ with</span><span>
</span><span id="line-1330"></span><span class="hs-comment">-- @SYMBOLIC_LINK_FLAG_DIRECTORY@.  Since 1.3.3.0, the</span><span>
</span><span id="line-1331"></span><span class="hs-comment">-- @SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE@ flag is also included if</span><span>
</span><span id="line-1332"></span><span class="hs-comment">-- supported by the operating system.   On POSIX, this is an alias for</span><span>
</span><span id="line-1333"></span><span class="hs-comment">-- 'createFileLink' and is therefore atomic.</span><span>
</span><span id="line-1334"></span><span class="hs-comment">--</span><span>
</span><span id="line-1335"></span><span class="hs-comment">-- Windows-specific errors: This operation may fail with 'permissionErrorType'</span><span>
</span><span id="line-1336"></span><span class="hs-comment">-- if the user lacks the privileges to create symbolic links.  It may also</span><span>
</span><span id="line-1337"></span><span class="hs-comment">-- fail with 'illegalOperationErrorType' if the file system does not support</span><span>
</span><span id="line-1338"></span><span class="hs-comment">-- symbolic links.</span><span>
</span><span id="line-1339"></span><span class="hs-comment">--</span><span>
</span><span id="line-1340"></span><span class="hs-comment">-- @since 1.3.1.0</span><span>
</span><span id="line-1341"></span><span class="annot"><a href="System.Directory.html#createDirectoryLink"><span class="hs-identifier hs-type">createDirectoryLink</span></a></span><span>
</span><span id="line-1342"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                           </span><span class="hs-comment">-- ^ path to the target directory</span><span>
</span><span id="line-1343"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                           </span><span class="hs-comment">-- ^ path of the link to be created</span><span>
</span><span id="line-1344"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1345"></span><span id="createDirectoryLink"><span class="annot"><span class="annottext">createDirectoryLink :: FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.html#createDirectoryLink"><span class="hs-identifier hs-var hs-var">createDirectoryLink</span></a></span></span><span> </span><span id="local-6989586621679048607"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048607"><span class="hs-identifier hs-var">target</span></a></span></span><span> </span><span id="local-6989586621679048606"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048606"><span class="hs-identifier hs-var">link</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1346"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;createDirectoryLink&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1347"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; FilePath -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#createSymbolicLink"><span class="hs-identifier hs-var">createSymbolicLink</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048607"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048606"><span class="hs-identifier hs-var">link</span></a></span><span>
</span><span id="line-1348"></span><span>
</span><span id="line-1349"></span><span class="hs-comment">-- | Remove an existing /directory/ symbolic link.</span><span>
</span><span id="line-1350"></span><span class="hs-comment">--</span><span>
</span><span id="line-1351"></span><span class="hs-comment">-- On Windows, this is an alias for 'removeDirectory'.  On POSIX systems, this</span><span>
</span><span id="line-1352"></span><span class="hs-comment">-- is an alias for 'removeFile'.</span><span>
</span><span id="line-1353"></span><span class="hs-comment">--</span><span>
</span><span id="line-1354"></span><span class="hs-comment">-- See also: 'removeFile', which can remove an existing /file/ symbolic link.</span><span>
</span><span id="line-1355"></span><span class="hs-comment">--</span><span>
</span><span id="line-1356"></span><span class="hs-comment">-- @since 1.3.1.0</span><span>
</span><span id="line-1357"></span><span class="annot"><a href="System.Directory.html#removeDirectoryLink"><span class="hs-identifier hs-type">removeDirectoryLink</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1358"></span><span id="removeDirectoryLink"><span class="annot"><span class="annottext">removeDirectoryLink :: FilePath -&gt; IO ()
</span><a href="System.Directory.html#removeDirectoryLink"><span class="hs-identifier hs-var hs-var">removeDirectoryLink</span></a></span></span><span> </span><span id="local-6989586621679048605"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048605"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1359"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;removeDirectoryLink&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1360"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; FilePath -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#removePathInternal"><span class="hs-identifier hs-var">removePathInternal</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="System.Directory.Internal.Windows.html#linkToDirectoryIsDirectory"><span class="hs-identifier hs-var">linkToDirectoryIsDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048605"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1361"></span><span>
</span><span id="line-1362"></span><span class="hs-comment">-- | Check whether an existing @path@ is a symbolic link.  If @path@ is a</span><span>
</span><span id="line-1363"></span><span class="hs-comment">-- regular file or directory, 'False' is returned.  If @path@ does not exist</span><span>
</span><span id="line-1364"></span><span class="hs-comment">-- or is otherwise inaccessible, an exception is thrown (see below).</span><span>
</span><span id="line-1365"></span><span class="hs-comment">--</span><span>
</span><span id="line-1366"></span><span class="hs-comment">-- On Windows, this checks for @FILE_ATTRIBUTE_REPARSE_POINT@.  In addition to</span><span>
</span><span id="line-1367"></span><span class="hs-comment">-- symbolic links, the function also returns true on junction points.  On</span><span>
</span><span id="line-1368"></span><span class="hs-comment">-- POSIX systems, this checks for @S_IFLNK@.</span><span>
</span><span id="line-1369"></span><span class="hs-comment">--</span><span>
</span><span id="line-1370"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-1371"></span><span class="hs-comment">--</span><span>
</span><span id="line-1372"></span><span class="hs-comment">-- * 'isDoesNotExistError' if the symbolic link does not exist; or</span><span>
</span><span id="line-1373"></span><span class="hs-comment">--</span><span>
</span><span id="line-1374"></span><span class="hs-comment">-- * 'isPermissionError' if the user is not permitted to read the symbolic</span><span>
</span><span id="line-1375"></span><span class="hs-comment">--   link.</span><span>
</span><span id="line-1376"></span><span class="hs-comment">--</span><span>
</span><span id="line-1377"></span><span class="hs-comment">-- @since 1.3.0.0</span><span>
</span><span id="line-1378"></span><span class="annot"><a href="System.Directory.html#pathIsSymbolicLink"><span class="hs-identifier hs-type">pathIsSymbolicLink</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1379"></span><span id="pathIsSymbolicLink"><span class="annot"><span class="annottext">pathIsSymbolicLink :: FilePath -&gt; IO Bool
</span><a href="System.Directory.html#pathIsSymbolicLink"><span class="hs-identifier hs-var hs-var">pathIsSymbolicLink</span></a></span></span><span> </span><span id="local-6989586621679048603"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048603"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1380"></span><span>  </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;pathIsSymbolicLink&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; (IOError -&gt; IOError) -&gt; IOError -&gt; IOError
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-1381"></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#ioeSetFileName"><span class="hs-operator hs-var">`ioeSetFileName`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048603"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO Bool -&gt; IO Bool
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1382"></span><span>     </span><span class="annot"><span class="annottext">FileType -&gt; Bool
</span><a href="System.Directory.Internal.Common.html#fileTypeIsLink"><span class="hs-identifier hs-var">fileTypeIsLink</span></a></span><span> </span><span class="annot"><span class="annottext">(FileType -&gt; Bool) -&gt; (Metadata -&gt; FileType) -&gt; Metadata -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Metadata -&gt; FileType
</span><a href="System.Directory.Internal.Windows.html#fileTypeFromMetadata"><span class="hs-identifier hs-var">fileTypeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">(Metadata -&gt; Bool) -&gt; IO Metadata -&gt; IO Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getSymbolicLinkMetadata"><span class="hs-identifier hs-var">getSymbolicLinkMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048603"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1383"></span><span>
</span><span id="line-1384"></span><span class="hs-pragma">{-# DEPRECATED</span><span> </span><span class="hs-pragma">isSymbolicLink</span><span> </span><span class="hs-pragma">&quot;Use 'pathIsSymbolicLink' instead&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-1385"></span><span class="annot"><a href="System.Directory.html#isSymbolicLink"><span class="hs-identifier hs-type">isSymbolicLink</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1386"></span><span id="isSymbolicLink"><span class="annot"><span class="annottext">isSymbolicLink :: FilePath -&gt; IO Bool
</span><a href="System.Directory.html#isSymbolicLink"><span class="hs-identifier hs-var hs-var">isSymbolicLink</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Bool
</span><a href="System.Directory.html#pathIsSymbolicLink"><span class="hs-identifier hs-var">pathIsSymbolicLink</span></a></span><span>
</span><span id="line-1387"></span><span>
</span><span id="line-1388"></span><span class="hs-comment">-- | Retrieve the target path of either a file or directory symbolic link.</span><span>
</span><span id="line-1389"></span><span class="hs-comment">-- The returned path may not be absolute, may not exist, and may not even be a</span><span>
</span><span id="line-1390"></span><span class="hs-comment">-- valid path.</span><span>
</span><span id="line-1391"></span><span class="hs-comment">--</span><span>
</span><span id="line-1392"></span><span class="hs-comment">-- On Windows systems, this calls @DeviceIoControl@ with</span><span>
</span><span id="line-1393"></span><span class="hs-comment">-- @FSCTL_GET_REPARSE_POINT@.  In addition to symbolic links, the function</span><span>
</span><span id="line-1394"></span><span class="hs-comment">-- also works on junction points.  On POSIX systems, this calls @readlink@.</span><span>
</span><span id="line-1395"></span><span class="hs-comment">--</span><span>
</span><span id="line-1396"></span><span class="hs-comment">-- Windows-specific errors: This operation may fail with</span><span>
</span><span id="line-1397"></span><span class="hs-comment">-- 'illegalOperationErrorType' if the file system does not support symbolic</span><span>
</span><span id="line-1398"></span><span class="hs-comment">-- links.</span><span>
</span><span id="line-1399"></span><span class="hs-comment">--</span><span>
</span><span id="line-1400"></span><span class="hs-comment">-- @since 1.3.1.0</span><span>
</span><span id="line-1401"></span><span class="annot"><a href="System.Directory.html#getSymbolicLinkTarget"><span class="hs-identifier hs-type">getSymbolicLinkTarget</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-1402"></span><span id="getSymbolicLinkTarget"><span class="annot"><span class="annottext">getSymbolicLinkTarget :: FilePath -&gt; IO FilePath
</span><a href="System.Directory.html#getSymbolicLinkTarget"><span class="hs-identifier hs-var hs-var">getSymbolicLinkTarget</span></a></span></span><span> </span><span id="local-6989586621679048601"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048601"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1403"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getSymbolicLinkTarget&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO FilePath -&gt; IO FilePath
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1404"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="System.Directory.Internal.Windows.html#readSymbolicLink"><span class="hs-identifier hs-var">readSymbolicLink</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048601"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1405"></span><span>
</span><span id="line-1406"></span><span class="hs-comment">-- | Obtain the time at which the file or directory was last accessed.</span><span>
</span><span id="line-1407"></span><span class="hs-comment">--</span><span>
</span><span id="line-1408"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-1409"></span><span class="hs-comment">--</span><span>
</span><span id="line-1410"></span><span class="hs-comment">-- * 'isPermissionError' if the user is not permitted to read</span><span>
</span><span id="line-1411"></span><span class="hs-comment">--   the access time; or</span><span>
</span><span id="line-1412"></span><span class="hs-comment">--</span><span>
</span><span id="line-1413"></span><span class="hs-comment">-- * 'isDoesNotExistError' if the file or directory does not exist.</span><span>
</span><span id="line-1414"></span><span class="hs-comment">--</span><span>
</span><span id="line-1415"></span><span class="hs-comment">-- Caveat for POSIX systems: This function returns a timestamp with sub-second</span><span>
</span><span id="line-1416"></span><span class="hs-comment">-- resolution only if this package is compiled against @unix-2.6.0.0@ or later</span><span>
</span><span id="line-1417"></span><span class="hs-comment">-- and the underlying filesystem supports them.</span><span>
</span><span id="line-1418"></span><span class="hs-comment">--</span><span>
</span><span id="line-1419"></span><span class="hs-comment">-- @since 1.2.3.0</span><span>
</span><span id="line-1420"></span><span class="hs-comment">--</span><span>
</span><span id="line-1421"></span><span class="annot"><a href="System.Directory.html#getAccessTime"><span class="hs-identifier hs-type">getAccessTime</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../time/src/Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span>
</span><span id="line-1422"></span><span id="getAccessTime"><span class="annot"><span class="annottext">getAccessTime :: FilePath -&gt; IO UTCTime
</span><a href="System.Directory.html#getAccessTime"><span class="hs-identifier hs-var hs-var">getAccessTime</span></a></span></span><span> </span><span id="local-6989586621679048599"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048599"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1423"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getAccessTime&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO UTCTime -&gt; IO UTCTime
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1424"></span><span>    </span><span class="annot"><span class="annottext">Metadata -&gt; UTCTime
</span><a href="System.Directory.Internal.Windows.html#accessTimeFromMetadata"><span class="hs-identifier hs-var">accessTimeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">(Metadata -&gt; UTCTime) -&gt; IO Metadata -&gt; IO UTCTime
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getFileMetadata"><span class="hs-identifier hs-var">getFileMetadata</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="System.Directory.Internal.Common.html#emptyToCurDir"><span class="hs-identifier hs-var">emptyToCurDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048599"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1425"></span><span>
</span><span id="line-1426"></span><span class="hs-comment">-- | Obtain the time at which the file or directory was last modified.</span><span>
</span><span id="line-1427"></span><span class="hs-comment">--</span><span>
</span><span id="line-1428"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-1429"></span><span class="hs-comment">--</span><span>
</span><span id="line-1430"></span><span class="hs-comment">-- * 'isPermissionError' if the user is not permitted to read</span><span>
</span><span id="line-1431"></span><span class="hs-comment">--   the modification time; or</span><span>
</span><span id="line-1432"></span><span class="hs-comment">--</span><span>
</span><span id="line-1433"></span><span class="hs-comment">-- * 'isDoesNotExistError' if the file or directory does not exist.</span><span>
</span><span id="line-1434"></span><span class="hs-comment">--</span><span>
</span><span id="line-1435"></span><span class="hs-comment">-- Caveat for POSIX systems: This function returns a timestamp with sub-second</span><span>
</span><span id="line-1436"></span><span class="hs-comment">-- resolution only if this package is compiled against @unix-2.6.0.0@ or later</span><span>
</span><span id="line-1437"></span><span class="hs-comment">-- and the underlying filesystem supports them.</span><span>
</span><span id="line-1438"></span><span class="hs-comment">--</span><span>
</span><span id="line-1439"></span><span class="annot"><a href="System.Directory.html#getModificationTime"><span class="hs-identifier hs-type">getModificationTime</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../time/src/Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span>
</span><span id="line-1440"></span><span id="getModificationTime"><span class="annot"><span class="annottext">getModificationTime :: FilePath -&gt; IO UTCTime
</span><a href="System.Directory.html#getModificationTime"><span class="hs-identifier hs-var hs-var">getModificationTime</span></a></span></span><span> </span><span id="local-6989586621679048598"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048598"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1441"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getModificationTime&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO UTCTime -&gt; IO UTCTime
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1442"></span><span>    </span><span class="annot"><span class="annottext">Metadata -&gt; UTCTime
</span><a href="System.Directory.Internal.Windows.html#modificationTimeFromMetadata"><span class="hs-identifier hs-var">modificationTimeFromMetadata</span></a></span><span> </span><span class="annot"><span class="annottext">(Metadata -&gt; UTCTime) -&gt; IO Metadata -&gt; IO UTCTime
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Metadata
</span><a href="System.Directory.Internal.Windows.html#getFileMetadata"><span class="hs-identifier hs-var">getFileMetadata</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="System.Directory.Internal.Common.html#emptyToCurDir"><span class="hs-identifier hs-var">emptyToCurDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048598"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1443"></span><span>
</span><span id="line-1444"></span><span class="hs-comment">-- | Change the time at which the file or directory was last accessed.</span><span>
</span><span id="line-1445"></span><span class="hs-comment">--</span><span>
</span><span id="line-1446"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-1447"></span><span class="hs-comment">--</span><span>
</span><span id="line-1448"></span><span class="hs-comment">-- * 'isPermissionError' if the user is not permitted to alter the</span><span>
</span><span id="line-1449"></span><span class="hs-comment">--   access time; or</span><span>
</span><span id="line-1450"></span><span class="hs-comment">--</span><span>
</span><span id="line-1451"></span><span class="hs-comment">-- * 'isDoesNotExistError' if the file or directory does not exist.</span><span>
</span><span id="line-1452"></span><span class="hs-comment">--</span><span>
</span><span id="line-1453"></span><span class="hs-comment">-- Some caveats for POSIX systems:</span><span>
</span><span id="line-1454"></span><span class="hs-comment">--</span><span>
</span><span id="line-1455"></span><span class="hs-comment">-- * Not all systems support @utimensat@, in which case the function can only</span><span>
</span><span id="line-1456"></span><span class="hs-comment">--   emulate the behavior by reading the modification time and then setting</span><span>
</span><span id="line-1457"></span><span class="hs-comment">--   both the access and modification times together.  On systems where</span><span>
</span><span id="line-1458"></span><span class="hs-comment">--   @utimensat@ is supported, the access time is set atomically with</span><span>
</span><span id="line-1459"></span><span class="hs-comment">--   nanosecond precision.</span><span>
</span><span id="line-1460"></span><span class="hs-comment">--</span><span>
</span><span id="line-1461"></span><span class="hs-comment">-- * If compiled against a version of @unix@ prior to @2.7.0.0@, the function</span><span>
</span><span id="line-1462"></span><span class="hs-comment">--   would not be able to set timestamps with sub-second resolution.  In this</span><span>
</span><span id="line-1463"></span><span class="hs-comment">--   case, there would also be loss of precision in the modification time.</span><span>
</span><span id="line-1464"></span><span class="hs-comment">--</span><span>
</span><span id="line-1465"></span><span class="hs-comment">-- @since 1.2.3.0</span><span>
</span><span id="line-1466"></span><span class="hs-comment">--</span><span>
</span><span id="line-1467"></span><span class="annot"><a href="System.Directory.html#setAccessTime"><span class="hs-identifier hs-type">setAccessTime</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../time/src/Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1468"></span><span id="setAccessTime"><span class="annot"><span class="annottext">setAccessTime :: FilePath -&gt; UTCTime -&gt; IO ()
</span><a href="System.Directory.html#setAccessTime"><span class="hs-identifier hs-var hs-var">setAccessTime</span></a></span></span><span> </span><span id="local-6989586621679048597"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048597"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679048596"><span class="annot"><span class="annottext">UTCTime
</span><a href="#local-6989586621679048596"><span class="hs-identifier hs-var">atime</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1469"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;setAccessTime&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1470"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; (Maybe UTCTime, Maybe UTCTime) -&gt; IO ()
</span><a href="System.Directory.html#setFileTimes"><span class="hs-identifier hs-var">setFileTimes</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048597"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UTCTime -&gt; Maybe UTCTime
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">UTCTime
</span><a href="#local-6989586621679048596"><span class="hs-identifier hs-var">atime</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe UTCTime
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1471"></span><span>
</span><span id="line-1472"></span><span class="hs-comment">-- | Change the time at which the file or directory was last modified.</span><span>
</span><span id="line-1473"></span><span class="hs-comment">--</span><span>
</span><span id="line-1474"></span><span class="hs-comment">-- The operation may fail with:</span><span>
</span><span id="line-1475"></span><span class="hs-comment">--</span><span>
</span><span id="line-1476"></span><span class="hs-comment">-- * 'isPermissionError' if the user is not permitted to alter the</span><span>
</span><span id="line-1477"></span><span class="hs-comment">--   modification time; or</span><span>
</span><span id="line-1478"></span><span class="hs-comment">--</span><span>
</span><span id="line-1479"></span><span class="hs-comment">-- * 'isDoesNotExistError' if the file or directory does not exist.</span><span>
</span><span id="line-1480"></span><span class="hs-comment">--</span><span>
</span><span id="line-1481"></span><span class="hs-comment">-- Some caveats for POSIX systems:</span><span>
</span><span id="line-1482"></span><span class="hs-comment">--</span><span>
</span><span id="line-1483"></span><span class="hs-comment">-- * Not all systems support @utimensat@, in which case the function can only</span><span>
</span><span id="line-1484"></span><span class="hs-comment">--   emulate the behavior by reading the access time and then setting both the</span><span>
</span><span id="line-1485"></span><span class="hs-comment">--   access and modification times together.  On systems where @utimensat@ is</span><span>
</span><span id="line-1486"></span><span class="hs-comment">--   supported, the modification time is set atomically with nanosecond</span><span>
</span><span id="line-1487"></span><span class="hs-comment">--   precision.</span><span>
</span><span id="line-1488"></span><span class="hs-comment">--</span><span>
</span><span id="line-1489"></span><span class="hs-comment">-- * If compiled against a version of @unix@ prior to @2.7.0.0@, the function</span><span>
</span><span id="line-1490"></span><span class="hs-comment">--   would not be able to set timestamps with sub-second resolution.  In this</span><span>
</span><span id="line-1491"></span><span class="hs-comment">--   case, there would also be loss of precision in the access time.</span><span>
</span><span id="line-1492"></span><span class="hs-comment">--</span><span>
</span><span id="line-1493"></span><span class="hs-comment">-- @since 1.2.3.0</span><span>
</span><span id="line-1494"></span><span class="hs-comment">--</span><span>
</span><span id="line-1495"></span><span class="annot"><a href="System.Directory.html#setModificationTime"><span class="hs-identifier hs-type">setModificationTime</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../time/src/Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1496"></span><span id="setModificationTime"><span class="annot"><span class="annottext">setModificationTime :: FilePath -&gt; UTCTime -&gt; IO ()
</span><a href="System.Directory.html#setModificationTime"><span class="hs-identifier hs-var hs-var">setModificationTime</span></a></span></span><span> </span><span id="local-6989586621679048595"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048595"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679048594"><span class="annot"><span class="annottext">UTCTime
</span><a href="#local-6989586621679048594"><span class="hs-identifier hs-var">mtime</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1497"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;setModificationTime&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1498"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; (Maybe UTCTime, Maybe UTCTime) -&gt; IO ()
</span><a href="System.Directory.html#setFileTimes"><span class="hs-identifier hs-var">setFileTimes</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048595"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe UTCTime
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UTCTime -&gt; Maybe UTCTime
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">UTCTime
</span><a href="#local-6989586621679048594"><span class="hs-identifier hs-var">mtime</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1499"></span><span>
</span><span id="line-1500"></span><span class="annot"><a href="System.Directory.html#setFileTimes"><span class="hs-identifier hs-type">setFileTimes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../time/src/Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../time/src/Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1501"></span><span id="setFileTimes"><span class="annot"><span class="annottext">setFileTimes :: FilePath -&gt; (Maybe UTCTime, Maybe UTCTime) -&gt; IO ()
</span><a href="System.Directory.html#setFileTimes"><span class="hs-identifier hs-var hs-var">setFileTimes</span></a></span></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe UTCTime
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe UTCTime
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1502"></span><span class="annot"><a href="System.Directory.html#setFileTimes"><span class="hs-identifier hs-var">setFileTimes</span></a></span><span> </span><span id="local-6989586621679048593"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048593"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679048592"><span class="annot"><span class="annottext">Maybe UTCTime
</span><a href="#local-6989586621679048592"><span class="hs-identifier hs-var">atime</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679048591"><span class="annot"><span class="annottext">Maybe UTCTime
</span><a href="#local-6989586621679048591"><span class="hs-identifier hs-var">mtime</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1503"></span><span>  </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;setFileTimes&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; (IOError -&gt; IOError) -&gt; IOError -&gt; IOError
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-1504"></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="../../base/src/System.IO.Error.html#ioeSetFileName"><span class="hs-operator hs-var">`ioeSetFileName`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048593"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO () -&gt; IO ()
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1505"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; (Maybe POSIXTime, Maybe POSIXTime) -&gt; IO ()
</span><a href="System.Directory.Internal.Windows.html#setTimes"><span class="hs-identifier hs-var">setTimes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="System.Directory.Internal.Common.html#emptyToCurDir"><span class="hs-identifier hs-var">emptyToCurDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048593"><span class="hs-identifier hs-var">path</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1506"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UTCTime -&gt; POSIXTime
</span><a href="../../time/src/Data.Time.Clock.POSIX.html#utcTimeToPOSIXSeconds"><span class="hs-identifier hs-var">utcTimeToPOSIXSeconds</span></a></span><span> </span><span class="annot"><span class="annottext">(UTCTime -&gt; POSIXTime) -&gt; Maybe UTCTime -&gt; Maybe POSIXTime
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe UTCTime
</span><a href="#local-6989586621679048592"><span class="hs-identifier hs-var">atime</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UTCTime -&gt; POSIXTime
</span><a href="../../time/src/Data.Time.Clock.POSIX.html#utcTimeToPOSIXSeconds"><span class="hs-identifier hs-var">utcTimeToPOSIXSeconds</span></a></span><span> </span><span class="annot"><span class="annottext">(UTCTime -&gt; POSIXTime) -&gt; Maybe UTCTime -&gt; Maybe POSIXTime
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe UTCTime
</span><a href="#local-6989586621679048591"><span class="hs-identifier hs-var">mtime</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1507"></span><span>
</span><span id="line-1508"></span><span class="hs-comment">{- | Returns the current user's home directory.

The directory returned is expected to be writable by the current user,
but note that it isn't generally considered good practice to store
application-specific data here; use 'getXdgDirectory' or
'getAppUserDataDirectory' instead.

On Unix, 'getHomeDirectory' behaves as follows:

* Returns $HOME env variable if set (including to an empty string).
* Otherwise uses home directory returned by `getpwuid_r` using the UID of the current proccesses user. This basically reads the /etc/passwd file. An empty home directory field is considered valid.

On Windows, the system is queried for a suitable path; a typical path might be @C:\/Users\//\&lt;user\&gt;/@.

The operation may fail with:

* @UnsupportedOperation@
The operating system has no notion of home directory.

* 'isDoesNotExistError'
The home directory for the current user does not exist, or
cannot be found.
-}</span><span>
</span><span id="line-1531"></span><span class="annot"><a href="System.Directory.html#getHomeDirectory"><span class="hs-identifier hs-type">getHomeDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-1532"></span><span id="getHomeDirectory"><span class="annot"><span class="annottext">getHomeDirectory :: IO FilePath
</span><a href="System.Directory.html#getHomeDirectory"><span class="hs-identifier hs-var hs-var">getHomeDirectory</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1533"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getHomeDirectory&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO FilePath -&gt; IO FilePath
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1534"></span><span>    </span><span class="annot"><span class="annottext">IO FilePath
</span><a href="System.Directory.Internal.Windows.html#getHomeDirectoryInternal"><span class="hs-identifier hs-var">getHomeDirectoryInternal</span></a></span><span>
</span><span id="line-1535"></span><span>
</span><span id="line-1536"></span><span class="hs-comment">-- | Obtain the paths to special directories for storing user-specific</span><span>
</span><span id="line-1537"></span><span class="hs-comment">--   application data, configuration, and cache files, conforming to the</span><span>
</span><span id="line-1538"></span><span class="hs-comment">--   &lt;http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html XDG Base Directory Specification&gt;.</span><span>
</span><span id="line-1539"></span><span class="hs-comment">--   Compared with 'getAppUserDataDirectory', this function provides a more</span><span>
</span><span id="line-1540"></span><span class="hs-comment">--   fine-grained hierarchy as well as greater flexibility for the user.</span><span>
</span><span id="line-1541"></span><span class="hs-comment">--</span><span>
</span><span id="line-1542"></span><span class="hs-comment">--   On Windows, 'XdgData' and 'XdgConfig' usually map to the same directory</span><span>
</span><span id="line-1543"></span><span class="hs-comment">--   unless overridden.</span><span>
</span><span id="line-1544"></span><span class="hs-comment">--</span><span>
</span><span id="line-1545"></span><span class="hs-comment">--   Refer to the docs of 'XdgDirectory' for more details.</span><span>
</span><span id="line-1546"></span><span class="hs-comment">--</span><span>
</span><span id="line-1547"></span><span class="hs-comment">--   The second argument is usually the name of the application.  Since it</span><span>
</span><span id="line-1548"></span><span class="hs-comment">--   will be integrated into the path, it must consist of valid path</span><span>
</span><span id="line-1549"></span><span class="hs-comment">--   characters.  Note: if the second argument is an absolute path, it will</span><span>
</span><span id="line-1550"></span><span class="hs-comment">--   just return the second argument.</span><span>
</span><span id="line-1551"></span><span class="hs-comment">--</span><span>
</span><span id="line-1552"></span><span class="hs-comment">--   Note: The directory may not actually exist, in which case you would need</span><span>
</span><span id="line-1553"></span><span class="hs-comment">--   to create it with file mode @700@ (i.e. only accessible by the owner).</span><span>
</span><span id="line-1554"></span><span class="hs-comment">--</span><span>
</span><span id="line-1555"></span><span class="hs-comment">--   As of 1.3.5.0, the environment variable is ignored if set to a relative</span><span>
</span><span id="line-1556"></span><span class="hs-comment">--   path, per revised XDG Base Directory Specification.  See</span><span>
</span><span id="line-1557"></span><span class="hs-comment">--   &lt;https://github.com/haskell/directory/issues/100 #100&gt;.</span><span>
</span><span id="line-1558"></span><span class="hs-comment">--</span><span>
</span><span id="line-1559"></span><span class="hs-comment">--   @since 1.2.3.0</span><span>
</span><span id="line-1560"></span><span class="annot"><a href="System.Directory.html#getXdgDirectory"><span class="hs-identifier hs-type">getXdgDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#XdgDirectory"><span class="hs-identifier hs-type">XdgDirectory</span></a></span><span>         </span><span class="hs-comment">-- ^ which special directory</span><span>
</span><span id="line-1561"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>             </span><span class="hs-comment">-- ^ a relative path that is appended</span><span>
</span><span id="line-1562"></span><span>                                        </span><span class="hs-comment">--   to the path; if empty, the base</span><span>
</span><span id="line-1563"></span><span>                                        </span><span class="hs-comment">--   path is returned</span><span>
</span><span id="line-1564"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-1565"></span><span id="getXdgDirectory"><span class="annot"><span class="annottext">getXdgDirectory :: XdgDirectory -&gt; FilePath -&gt; IO FilePath
</span><a href="System.Directory.html#getXdgDirectory"><span class="hs-identifier hs-var hs-var">getXdgDirectory</span></a></span></span><span> </span><span id="local-6989586621679048588"><span class="annot"><span class="annottext">XdgDirectory
</span><a href="#local-6989586621679048588"><span class="hs-identifier hs-var">xdgDir</span></a></span></span><span> </span><span id="local-6989586621679048587"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048587"><span class="hs-identifier hs-var">suffix</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1566"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getXdgDirectory&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO FilePath -&gt; IO FilePath
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1567"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="System.Directory.Internal.Windows.html#simplify"><span class="hs-identifier hs-var">simplify</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048587"><span class="hs-identifier hs-var">suffix</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath) -&gt; IO FilePath -&gt; IO FilePath
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1568"></span><span>      </span><span id="local-6989586621679048586"><span class="annot"><span class="annottext">Maybe FilePath
</span><a href="#local-6989586621679048586"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO (Maybe FilePath)
</span><a href="../../base/src/System.Environment.html#lookupEnv"><span class="hs-identifier hs-var">lookupEnv</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO (Maybe FilePath))
-&gt; FilePath -&gt; IO (Maybe FilePath)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">XdgDirectory
</span><a href="#local-6989586621679048588"><span class="hs-identifier hs-var">xdgDir</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1569"></span><span>        </span><span class="annot"><span class="annottext">XdgDirectory
</span><a href="System.Directory.Internal.Common.html#XdgData"><span class="hs-identifier hs-var">XdgData</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;XDG_DATA_HOME&quot;</span></span><span>
</span><span id="line-1570"></span><span>        </span><span class="annot"><span class="annottext">XdgDirectory
</span><a href="System.Directory.Internal.Common.html#XdgConfig"><span class="hs-identifier hs-var">XdgConfig</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;XDG_CONFIG_HOME&quot;</span></span><span>
</span><span id="line-1571"></span><span>        </span><span class="annot"><span class="annottext">XdgDirectory
</span><a href="System.Directory.Internal.Common.html#XdgCache"><span class="hs-identifier hs-var">XdgCache</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;XDG_CACHE_HOME&quot;</span></span><span>
</span><span id="line-1572"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe FilePath
</span><a href="#local-6989586621679048586"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1573"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048581"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048581"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Bool
</span><a href="../../filepath/src/System.FilePath.Windows.html#isAbsolute"><span class="hs-identifier hs-var">isAbsolute</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048581"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048581"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-1574"></span><span>        </span><span class="annot"><span class="annottext">Maybe FilePath
</span><span class="hs-identifier">_</span></span><span>                           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO FilePath -&gt; XdgDirectory -&gt; IO FilePath
</span><a href="System.Directory.Internal.Windows.html#getXdgDirectoryFallback"><span class="hs-identifier hs-var">getXdgDirectoryFallback</span></a></span><span> </span><span class="annot"><span class="annottext">IO FilePath
</span><a href="System.Directory.html#getHomeDirectory"><span class="hs-identifier hs-var">getHomeDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">XdgDirectory
</span><a href="#local-6989586621679048588"><span class="hs-identifier hs-var">xdgDir</span></a></span><span>
</span><span id="line-1575"></span><span>
</span><span id="line-1576"></span><span class="hs-comment">-- | Similar to 'getXdgDirectory' but retrieves the entire list of XDG</span><span>
</span><span id="line-1577"></span><span class="hs-comment">-- directories.</span><span>
</span><span id="line-1578"></span><span class="hs-comment">--</span><span>
</span><span id="line-1579"></span><span class="hs-comment">-- On Windows, 'XdgDataDirs' and 'XdgConfigDirs' usually map to the same list</span><span>
</span><span id="line-1580"></span><span class="hs-comment">-- of directories unless overridden.</span><span>
</span><span id="line-1581"></span><span class="hs-comment">--</span><span>
</span><span id="line-1582"></span><span class="hs-comment">-- Refer to the docs of 'XdgDirectoryList' for more details.</span><span>
</span><span id="line-1583"></span><span class="annot"><a href="System.Directory.html#getXdgDirectoryList"><span class="hs-identifier hs-type">getXdgDirectoryList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Directory.Internal.Common.html#XdgDirectoryList"><span class="hs-identifier hs-type">XdgDirectoryList</span></a></span><span> </span><span class="hs-comment">-- ^ which special directory list</span><span>
</span><span id="line-1584"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1585"></span><span id="getXdgDirectoryList"><span class="annot"><span class="annottext">getXdgDirectoryList :: XdgDirectoryList -&gt; IO [FilePath]
</span><a href="System.Directory.html#getXdgDirectoryList"><span class="hs-identifier hs-var hs-var">getXdgDirectoryList</span></a></span></span><span> </span><span id="local-6989586621679048579"><span class="annot"><span class="annottext">XdgDirectoryList
</span><a href="#local-6989586621679048579"><span class="hs-identifier hs-var">xdgDirs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1586"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getXdgDirectoryList&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO [FilePath] -&gt; IO [FilePath]
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1587"></span><span>    </span><span id="local-6989586621679048578"><span class="annot"><span class="annottext">Maybe FilePath
</span><a href="#local-6989586621679048578"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO (Maybe FilePath)
</span><a href="../../base/src/System.Environment.html#lookupEnv"><span class="hs-identifier hs-var">lookupEnv</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO (Maybe FilePath))
-&gt; FilePath -&gt; IO (Maybe FilePath)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">XdgDirectoryList
</span><a href="#local-6989586621679048579"><span class="hs-identifier hs-var">xdgDirs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1588"></span><span>      </span><span class="annot"><span class="annottext">XdgDirectoryList
</span><a href="System.Directory.Internal.Common.html#XdgDataDirs"><span class="hs-identifier hs-var">XdgDataDirs</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;XDG_DATA_DIRS&quot;</span></span><span>
</span><span id="line-1589"></span><span>      </span><span class="annot"><span class="annottext">XdgDirectoryList
</span><a href="System.Directory.Internal.Common.html#XdgConfigDirs"><span class="hs-identifier hs-var">XdgConfigDirs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;XDG_CONFIG_DIRS&quot;</span></span><span>
</span><span id="line-1590"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe FilePath
</span><a href="#local-6989586621679048578"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1591"></span><span>      </span><span class="annot"><span class="annottext">Maybe FilePath
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">XdgDirectoryList -&gt; IO [FilePath]
</span><a href="System.Directory.Internal.Windows.html#getXdgDirectoryListFallback"><span class="hs-identifier hs-var">getXdgDirectoryListFallback</span></a></span><span> </span><span class="annot"><span class="annottext">XdgDirectoryList
</span><a href="#local-6989586621679048579"><span class="hs-identifier hs-var">xdgDirs</span></a></span><span>
</span><span id="line-1592"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679048574"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048574"><span class="hs-identifier hs-var">paths</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[FilePath] -&gt; IO [FilePath]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; [FilePath]
</span><a href="../../filepath/src/System.FilePath.Windows.html#splitSearchPath"><span class="hs-identifier hs-var">splitSearchPath</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048574"><span class="hs-identifier hs-var">paths</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1593"></span><span>
</span><span id="line-1594"></span><span class="hs-comment">-- | Obtain the path to a special directory for storing user-specific</span><span>
</span><span id="line-1595"></span><span class="hs-comment">--   application data (traditional Unix location).  Newer applications may</span><span>
</span><span id="line-1596"></span><span class="hs-comment">--   prefer the the XDG-conformant location provided by 'getXdgDirectory'</span><span>
</span><span id="line-1597"></span><span class="hs-comment">--   (&lt;https://github.com/haskell/directory/issues/6#issuecomment-96521020 migration guide&gt;).</span><span>
</span><span id="line-1598"></span><span class="hs-comment">--</span><span>
</span><span id="line-1599"></span><span class="hs-comment">--   The argument is usually the name of the application.  Since it will be</span><span>
</span><span id="line-1600"></span><span class="hs-comment">--   integrated into the path, it must consist of valid path characters.</span><span>
</span><span id="line-1601"></span><span class="hs-comment">--</span><span>
</span><span id="line-1602"></span><span class="hs-comment">--   * On Unix-like systems, the path is @~\/./\&lt;app\&gt;/@.</span><span>
</span><span id="line-1603"></span><span class="hs-comment">--   * On Windows, the path is @%APPDATA%\//\&lt;app\&gt;/@</span><span>
</span><span id="line-1604"></span><span class="hs-comment">--     (e.g. @C:\/Users\//\&lt;user\&gt;/\/AppData\/Roaming\//\&lt;app\&gt;/@)</span><span>
</span><span id="line-1605"></span><span class="hs-comment">--</span><span>
</span><span id="line-1606"></span><span class="hs-comment">--   Note: the directory may not actually exist, in which case you would need</span><span>
</span><span id="line-1607"></span><span class="hs-comment">--   to create it.  It is expected that the parent directory exists and is</span><span>
</span><span id="line-1608"></span><span class="hs-comment">--   writable.</span><span>
</span><span id="line-1609"></span><span class="hs-comment">--</span><span>
</span><span id="line-1610"></span><span class="hs-comment">--   The operation may fail with:</span><span>
</span><span id="line-1611"></span><span class="hs-comment">--</span><span>
</span><span id="line-1612"></span><span class="hs-comment">--   * @UnsupportedOperation@</span><span>
</span><span id="line-1613"></span><span class="hs-comment">--     The operating system has no notion of application-specific data</span><span>
</span><span id="line-1614"></span><span class="hs-comment">--     directory.</span><span>
</span><span id="line-1615"></span><span class="hs-comment">--</span><span>
</span><span id="line-1616"></span><span class="hs-comment">--   * 'isDoesNotExistError'</span><span>
</span><span id="line-1617"></span><span class="hs-comment">--     The home directory for the current user does not exist, or cannot be</span><span>
</span><span id="line-1618"></span><span class="hs-comment">--     found.</span><span>
</span><span id="line-1619"></span><span class="hs-comment">--</span><span>
</span><span id="line-1620"></span><span class="annot"><a href="System.Directory.html#getAppUserDataDirectory"><span class="hs-identifier hs-type">getAppUserDataDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>     </span><span class="hs-comment">-- ^ a relative path that is appended</span><span>
</span><span id="line-1621"></span><span>                                        </span><span class="hs-comment">--   to the path</span><span>
</span><span id="line-1622"></span><span>                        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-1623"></span><span id="getAppUserDataDirectory"><span class="annot"><span class="annottext">getAppUserDataDirectory :: FilePath -&gt; IO FilePath
</span><a href="System.Directory.html#getAppUserDataDirectory"><span class="hs-identifier hs-var hs-var">getAppUserDataDirectory</span></a></span></span><span> </span><span id="local-6989586621679048573"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048573"><span class="hs-identifier hs-var">appName</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1624"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getAppUserDataDirectory&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO FilePath -&gt; IO FilePath
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1625"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
</span><a href="System.Directory.Internal.Windows.html#getAppUserDataDirectoryInternal"><span class="hs-identifier hs-var">getAppUserDataDirectoryInternal</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679048573"><span class="hs-identifier hs-var">appName</span></a></span><span>
</span><span id="line-1626"></span><span>
</span><span id="line-1627"></span><span class="hs-comment">{- | Returns the current user's document directory.

The directory returned is expected to be writable by the current user,
but note that it isn't generally considered good practice to store
application-specific data here; use 'getXdgDirectory' or
'getAppUserDataDirectory' instead.

On Unix, 'getUserDocumentsDirectory' returns the value of the @HOME@
environment variable.  On Windows, the system is queried for a
suitable path; a typical path might be @C:\/Users\//\&lt;user\&gt;/\/Documents@.

The operation may fail with:

* @UnsupportedOperation@
The operating system has no notion of document directory.

* 'isDoesNotExistError'
The document directory for the current user does not exist, or
cannot be found.
-}</span><span>
</span><span id="line-1647"></span><span class="annot"><a href="System.Directory.html#getUserDocumentsDirectory"><span class="hs-identifier hs-type">getUserDocumentsDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-1648"></span><span id="getUserDocumentsDirectory"><span class="annot"><span class="annottext">getUserDocumentsDirectory :: IO FilePath
</span><a href="System.Directory.html#getUserDocumentsDirectory"><span class="hs-identifier hs-var hs-var">getUserDocumentsDirectory</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1649"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError -&gt; FilePath -&gt; IOError
</span><a href="System.Directory.Internal.Common.html#ioeAddLocation"><span class="hs-operator hs-var">`ioeAddLocation`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;getUserDocumentsDirectory&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IOError) -&gt; IO FilePath -&gt; IO FilePath
forall a. (IOError -&gt; IOError) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/System.IO.Error.html#modifyIOError"><span class="hs-operator hs-var">`modifyIOError`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1650"></span><span>    </span><span class="annot"><span class="annottext">IO FilePath
</span><a href="System.Directory.Internal.Windows.html#getUserDocumentsDirectoryInternal"><span class="hs-identifier hs-var">getUserDocumentsDirectoryInternal</span></a></span><span>
</span><span id="line-1651"></span><span>
</span><span id="line-1652"></span><span class="hs-comment">{- | Returns the current directory for temporary files.

On Unix, 'getTemporaryDirectory' returns the value of the @TMPDIR@
environment variable or \&quot;\/tmp\&quot; if the variable isn\'t defined.
On Windows, the function checks for the existence of environment variables in
the following order and uses the first path found:

*
TMP environment variable.

*
TEMP environment variable.

*
USERPROFILE environment variable.

*
The Windows directory

The operation may fail with:

* @UnsupportedOperation@
The operating system has no notion of temporary directory.

The function doesn\'t verify whether the path exists.
-}</span><span>
</span><span id="line-1678"></span><span class="annot"><a href="System.Directory.html#getTemporaryDirectory"><span class="hs-identifier hs-type">getTemporaryDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-1679"></span><span id="getTemporaryDirectory"><span class="annot"><span class="annottext">getTemporaryDirectory :: IO FilePath
</span><a href="System.Directory.html#getTemporaryDirectory"><span class="hs-identifier hs-var hs-var">getTemporaryDirectory</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO FilePath
</span><a href="System.Directory.Internal.Windows.html#getTemporaryDirectoryInternal"><span class="hs-identifier hs-var">getTemporaryDirectoryInternal</span></a></span><span>
</span><span id="line-1680"></span></pre></body></html>